TypeError: 'QAction' object is not callable



  • I'm trying to call a function when the user clicks on my help bar item. The error I get is TypeError: 'QAction' object is not callable
    How do I fix this? I'm loading stuff from my ui file. Here is an example:

    class MainWindow(QtGui.QMainWindow):
        def __init__(self):
            super(MainWindow, self).__init__()
            uic.loadUi('untitled.ui', self)
            self.show()
            self.actionD.triggered.connect(lambda: self.help())
        def help(self):
            print('help')
    if __name__ == '__main__':
        app = QtGui.QApplication(sys.argv)
        windowObj = MainWindow()
        sys.exit(app.exec_())
    
    
    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>MainWindow</class>
     <widget class="QMainWindow" name="MainWindow">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>800</width>
        <height>600</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>MainWindow</string>
      </property>
      <widget class="QWidget" name="centralwidget"/>
      <widget class="QMenuBar" name="menubar">
       <property name="geometry">
        <rect>
         <x>0</x>
         <y>0</y>
         <width>800</width>
         <height>25</height>
        </rect>
       </property>
       <widget class="QMenu" name="menuHelp">
        <property name="title">
         <string>Help</string>
        </property>
        <addaction name="action"/>
       </widget>
       <addaction name="menuHelp"/>
      </widget>
      <widget class="QStatusBar" name="statusbar"/>
      <action name="action">
       <property name="text">
        <string>Click me</string>
       </property>
      </action>
     </widget>
     <resources/>
     <connections/>
    </ui>
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.