Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Using two different keys for an Action

    Qt for Python
    1
    1
    31
    Loading More Posts
    • 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.
    • D
      dschiller last edited by SGaist

      How can I use two different keys for a QAction ?

      from PyQt5.QtWidgets import QAction
      from PyQt5.QtCore import Qt
      
      action = QAction('Any Action', self)
      action.setShortcut(Qt.Key.Key_Enter or Qt.Key.Key_Return)
      

      Found a solution.

      from PyQt5.QtWidgets import QAction
      from PyQt5.QtCore import Qt
      
      shortcuts = [Qt.Key.Key_Enter, Qt.Key.Key_Return]
      action = QAction('Any Action', self)
      action.setShortcuts(shortcuts)
      
      1 Reply Last reply Reply Quote 0
      • Topic has been marked as solved  SGaist SGaist 
      • First post
        Last post