组合两个 QMainWindows
pythonistas 和其他编码人群大家好,
我有两个单独设计和编码的 QMainWindows。 我需要:
- 首先显示
- 在按下按钮时
- 关闭第一个窗口构造并使用第一个窗口构造中的参数显示第二个窗口
我尝试设计第三个类来控制流程,但它不理解我的信号/槽尝试:
QtCore.QObject.connect(self.firstWindow,QtCore.SIGNAL("destroyed()"),self.openSecondWindow)
哦,大师们,您能启发我一些聪明的方法或机智的技巧来解决我的困难吗?
干杯。
Good day pythonistas and the rest of the coding crowd,
I have two QMainWindows designed and coded separately. I need to:
- display first
- on a button-press close the first window
- construct and display the second window using the arguments from the first
I have tried to design a third class to control the flow but it does not understand my signal/slot attempt:
QtCore.QObject.connect(self.firstWindow,QtCore.SIGNAL("destroyed()"),self.openSecondWindow)
Oh gurus, would you enlighten me on some clever way or a witty hack to solve my hardships.
Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答:
我最近在连接信号时遇到了一些问题。 我发现当我从 QtCore.SIGNAL 中删除括号时它就起作用了。
尝试将其更改
为
: 参考:
这是因为您正在使用 Riverbank 的“旧式”信号/槽。 这是文档参考。 具体来说,这是您要查找的行:
另外:
确保您的
this.FirstWindow
类在__init__(self...) 之前有此行:
Answer:
I had some trouble with connecting signals recently. I found that it worked when I removed the parentheses from the
QtCore.SIGNAL
.try changing this:
to this:
Reference:
This is because your are using the "old style" signals/slots according to Riverbank. Here's the reference to the docs. Specifically, this is the line you're looking for:
Also:
Make sure your
this.FirstWindow
class has this line before your__init__(self...)
:好吧,我已经放弃了控件类(下次将把控件作为第一件事,然后才制作窗口)
而是通过将秒的构造函数种子注入第一个类的主体中来匹配窗口,然后
self.close()
年轻的母亲。 太悲惨了。Well, I have given up on the control class (next time will make the control as the first thing and only after that make the windows)
Instead have mated the windows by injecting the seconds' constructor seed into the body of the first one and then
self.close()
the young mother. So tragic.