0
我在打開主窗口的pyqt小部件彈出窗口時出現問題。小工具在主窗口中打開。 按鈕,文本和框似乎在主窗口中混合並且不作爲單獨的窗口/小部件打開。Python Pyqt小部件無法正確顯示
如果需要,我可以稍後發佈圖片。
下面是一些代碼,希望只有重要的部分;
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.tableWidget.doubleClicked.connect(self.open_item_widget)
def open_item_widget(self):
self.item_widget = ItemWidget(self)
self.item_widget.show()
class ItemWidget(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_itemWidget()
self.ui.setupUi(self)
self.ui.cancelOkButtonBox.rejected.connect(self.close)
self.ui.cancelOkButtonBox.accepted.connect(self.submit_changes)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
mainwindow = MainWindow()
mainwindow.show()
sys.exit(app.exec_())
謝謝你的一切幫助。
謝謝!完美的作品。 – JohnBoy
@JohnBoy見http://stackoverflow.com/a/35523786/1559401如果你有興趣爲什麼這個工作。 – rbaleksandar