Question

I have a QMainWindow with a toolbar that has a bunch of QIcon buttons. Clicking these buttons switches between widgets in a QStackedWidget. Basically, the buttons function as tabs, opening different parts of the program. Now, what I want to do is make a specific button look pressed down when the corresponding widget is active, so it's easier to see which part of the program is active. Like this:

I rephrased it 20 different ways while Googling and checked out the manual but I'm still at a loss. I'm probably missing something painfully obvious here.

Was it helpful?

Solution

Of course I was missing something painfully obvious :P Here's the solution:

# Create the button and make it checkable
self.testButton = QtGui.QAction(QtGui.QIcon('images/icons/test.png'), 'Test', self)
self.testButton.setCheckable(True)

# Mark the button as checked
self.testButton.setChecked(True)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top