我有问题显示用户输入一些数据的QWidget窗口。显示没有MainWindow的Qwidget窗口
我的脚本没有GUI,但我只想显示这个小QWidget窗口。
我创建了QtDesigner窗口,现在我试图展现QWidget的窗口是这样的:
from PyQt4 import QtGui
from input_data_window import Ui_Form
class childInputData(QtGui.QWidget):
def __init__(self, parent=None):
super(childInputData, self).__init__()
self.ui = Ui_Form()
self.ui.setupUi(self)
self.setFocus(True)
self.show()
,然后从我的主类,我做这样的:
class myMainClass():
childWindow = childInputData()
这给我的错误:
QWidget: Must construct a QApplication before a QPaintDevice
所以,现在我做,从我的主类:
class myMainClass():
app = QtGui.QApplication(sys.argv)
childWindow = childInputData()
现在没有错误,但是窗口显示两次,脚本不会等待输入数据,它只是显示窗口并继续等待。
这里有什么问题?
关于显示两次的窗口,我看不出为什么在您发布的代码中。你确定你不在代码中的其他地方调用show()吗? – Mel
是的,我是:S .....我的错 – codeKiller