Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. TypeError: 'QAction' object is not callable
Qt 6.11 is out! See what's new in the release blog

TypeError: 'QAction' object is not callable

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cvanclee
    wrote on last edited by cvanclee
    #1

    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>
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved