alphanumeric
alphanumeric

Reputation: 19329

How to make toggle-able QAction

Is there a way to make QAction stay down after it is clicked. Ideally it could toggle between two states: On (down) and Off (up)?

Upvotes: 0

Views: 2843

Answers (2)

Oliver
Oliver

Reputation: 29463

What you are looking for is a toggle button. This is implemented in Qt via the checkable property: if an action is checkable, then when the action is in a button the button is a toggle button; when the action is in a menu item you see a checkmark; etc.

Upvotes: 1

alphanumeric
alphanumeric

Reputation: 19329

action = QtGui.QAction(QtGui.QIcon("myicon.png"),"Action Name", None)
action.setCheckable(True)
action.setStatusTip("Tooltip") 
action.setShortcut("Ctrl+D")  
action.triggered.connect(actionTrigged)

Upvotes: 1

Related Questions