如何在pyqt4中将两个窗口绑定在一起 [英] How to tie two windows together in pyqt4

查看:118
本文介绍了如何在pyqt4中将两个窗口绑定在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个在 qt4 设计器中制作的 pyqt 文件.我把它们都放在一个目录中,并在目录外创建了一个文件,我用它导入了它们.第一个文件是一个带有按钮的窗口,单击该按钮时,应关闭第一个窗口,并打开第二个窗口.

I have two pyqt files that I made in qt4 designer. I put them both in a directory and created a file outside the directory, which I imported them with. The first file is a window with a button, that when clicked, should close the first window, and open the second window.

我可以导入它们,然后同时启动它们,但我不知道如何让第一个窗口中的按钮影响另一个窗口,但单独让它自己关闭并生成另一个.

I can import them, and launch them both at the same time, but I can't figure out how to have the button in the first window affect the other, yet alone have it close itself and spawn the other.

推荐答案

在第一个窗口中单击按钮的处理程序中,实例化第二个窗口并调用其show-方法,然后关闭(发出关闭信号)第一个窗口.

In the handler of the button-click in the first window, instantiate the second window and invoke its show-method, and then close (emit the close-signal to) the first window.

这篇关于如何在pyqt4中将两个窗口绑定在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆