Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PySide6 NameError: name 'SLOT' is not defined in QTimer example documentation
Forum Updated to NodeBB v4.3 + New Features

PySide6 NameError: name 'SLOT' is not defined in QTimer example documentation

Scheduled Pinned Locked Moved Solved Qt for Python
3 Posts 2 Posters 853 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.
  • E Offline
    E Offline
    Erriez
    wrote on 8 Jan 2023, 11:06 last edited by Erriez 1 Aug 2023, 14:33
    #1

    PIP PySide 6.4.1 QTimer documentation contains the following example:

    from PySide6.QtWidgets import QApplication
    from PySide6.QtCore import QTimer
    import sys
    
    if __name__ == "__main__":
        app = QApplication([])
        QTimer.singleShot(600000, app, SLOT(quit()))
        ...
        sys.exit(app.exec())
    

    When running the example, it generates the following error:

    Traceback (most recent call last):
      File "qtimer_singleshot.py", line 8, in <module>
        QTimer.singleShot(600000, app, SLOT(quit()))
    NameError: name 'SLOT' is not defined
    

    The function prototype is static PySide6.QtCore.QTimer.singleShot(msec, receiver, member) where the last argument member is a str. Changing this line to QTimer.singleShot(10, app, 'quit()') generates a exit code 139 (interrupted by signal 11: SIGSEGV).

    I assume the example in the documentation is incorrect. What is the correct usage?

    J 1 Reply Last reply 9 Jan 2023, 14:18
    0
    • E Erriez
      8 Jan 2023, 11:06

      PIP PySide 6.4.1 QTimer documentation contains the following example:

      from PySide6.QtWidgets import QApplication
      from PySide6.QtCore import QTimer
      import sys
      
      if __name__ == "__main__":
          app = QApplication([])
          QTimer.singleShot(600000, app, SLOT(quit()))
          ...
          sys.exit(app.exec())
      

      When running the example, it generates the following error:

      Traceback (most recent call last):
        File "qtimer_singleshot.py", line 8, in <module>
          QTimer.singleShot(600000, app, SLOT(quit()))
      NameError: name 'SLOT' is not defined
      

      The function prototype is static PySide6.QtCore.QTimer.singleShot(msec, receiver, member) where the last argument member is a str. Changing this line to QTimer.singleShot(10, app, 'quit()') generates a exit code 139 (interrupted by signal 11: SIGSEGV).

      I assume the example in the documentation is incorrect. What is the correct usage?

      J Online
      J Online
      JonB
      wrote on 9 Jan 2023, 14:18 last edited by
      #2

      @Erriez
      Sadly many of the PySide examples are copied literally from C++ and are incorrect. I believe the correct call here for PySide6 is (untested)

      QTimer.singleShot(600000, app.quit)
      
      E 1 Reply Last reply 9 Jan 2023, 18:56
      1
      • J JonB
        9 Jan 2023, 14:18

        @Erriez
        Sadly many of the PySide examples are copied literally from C++ and are incorrect. I believe the correct call here for PySide6 is (untested)

        QTimer.singleShot(600000, app.quit)
        
        E Offline
        E Offline
        Erriez
        wrote on 9 Jan 2023, 18:56 last edited by
        #3

        @JonB Thanks a lot for your help. Your code works perfect! It is really that simple.

        I've created PYSIDE-2182 to update the documentation.

        1 Reply Last reply
        0

        1/3

        8 Jan 2023, 11:06

        • Login

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