Nominate our 2022 Qt Champions!

conflict between QWidget (window) and mainWindow

  • Hi, i'am new of Pyqt4.

    In my project when the window lose the focus and i try to click a MenuButton in mainWindow, the project crash!!! Why? Please help me!!
    this is my mainWindow code:
    help = QAction(self.getIcon(QStyle.SP_MessageBoxQuestion), 'Help', self)
    self.connect(help, QtCore.SIGNAL('triggered()'), self.helpAction)

    def helpAction(self):
    a = Help()

    and this is my Widget code:

    class Help(QtGui.QWidget):
    def init(self):
    self.setWindowTitle(' Help')
    ok = QtGui.QPushButton("Close", self)
    self.connect(ok, QtCore.SIGNAL('clicked()'), QtCore.SLOT('hide()'))
    about = QtGui.QTextBrowser(self)
    about.setMinimumSize(400, 400)
    grid = QtGui.QGridLayout(self)
    grid.addWidget(about, 2, 0, 5, 3)
    grid.addWidget(ok, 7, 1)

  • You might find more help in Pyqt4 but code you shown is not complete to give any advice.
    Something wrong probably happens in slot called.
    If it is helpAction you may try to comment lines started with a.init() and up and see what causes failure.

Log in to reply