组合两个 QMainWindows

发布于 2024-07-30 08:57:59 字数 367 浏览 8 评论 0原文

pythonistas 和其他编码人群大家好,

我有两个单独设计和编码的 QMainWindows。 我需要:

  1. 首先显示
  2. 在按下按钮时
  3. 关闭第一个窗口构造并使用第一个窗口构造中的参数显示第二个窗口

我尝试设计第三个类来控制流程,但它不理解我的信号/槽尝试:

 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:

  1. display first
  2. on a button-press close the first window
  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

£噩梦荏苒 2024-08-06 08:57:59

答:

我最近在连接信号时遇到了一些问题。 我发现当我从 QtCore.SIGNAL 中删除括号时它就起作用了。

尝试将其更改

QtCore.SIGNAL("destroyed()")

QtCore.SIGNAL("destroyed")

参考:

这是因为您正在使用 Riverbank 的“旧式”信号/槽。 这是文档参考。 具体来说,这是您要查找的行:

QtCore.QObject.connect(a, QtCore.SIGNAL("PySig"), pyFunction)

另外:

确保您的 this.FirstWindow 类在 __init__(self...) 之前有此行:

__pyqtSignals__ = ( "destroyed" )

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:

QtCore.SIGNAL("destroyed()")

to this:

QtCore.SIGNAL("destroyed")

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:

QtCore.QObject.connect(a, QtCore.SIGNAL("PySig"), pyFunction)

Also:

Make sure your this.FirstWindow class has this line before your __init__(self...):

__pyqtSignals__ = ( "destroyed" )
无人问我粥可暖 2024-08-06 08:57:59

好吧,我已经放弃了控件类(下次将把控件作为第一件事,然后才制作窗口)

而是通过将秒的构造函数种子注入第一个类的主体中来匹配窗口,然后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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文