Hi,

i'm writing a PyQT program. I've set up a Qtoolbar with a QtoolButton, which shows a menu of 3 buttons with 3 different icons.

The problem is that the QToolButton shows *always* the icon of the first action (this happens if I click on the second and on third...).

If I click on second action, the "checkable" state of the button is visible on the menu, but the toolbutton shows still the first action, as you can see in this image:

problem-qtoolbutton.PNG



Can you tell me if this code is correct?

Qt Code:
  1. # ACTIONS
  2.  
  3. self.actionFirstBut = QAction(QIcon(":/plugins/FIRST.png"), \
  4. "First button", self.iface.mainWindow())
  5. self.actionFirstBut.setCheckable (True)
  6. QObject.connect(self.actionFirstBut, SIGNAL("activated()"), self.runFirst)
  7.  
  8. [...]
  9.  
  10.  
  11. # TOOLBAR
  12.  
  13. self.topToolbar = self.iface.addToolBar ( "test" )
  14. self.topToolbar.setObjectName ("test")
  15.  
  16.  
  17. # TOOLBUTTON
  18.  
  19. self.civiciToolButton = QToolButton()
  20. self.civiciToolButton.setPopupMode( QToolButton.InstantPopup )
  21. self.civiciToolButton.setAutoRaise( True )
  22. self.civiciToolButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
  23. self.civiciToolButton.setCheckable( True )
  24.  
  25. self.civiciToolButton.addAction( self.actionFirstBut )
  26. self.civiciToolButton.addAction( self.actionSecondBut )
  27. self.civiciToolButton.addAction( self.actionThirdButton )
  28.  
  29. self.civiciToolButton.setDefaultAction( self.actionFirstBut )
  30.  
  31. self.topToolbar.addWidget( self.civiciToolButton )
To copy to clipboard, switch view to plain text mode