[PyQt] QMapTool problem

luca_manganelli at comune.trento.it luca_manganelli at comune.trento.it
Mon Sep 13 08:04:44 BST 2010


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 button (this if I
click on the second and on third...).

If I click on the qtoolbutton, the menu shows all three icons correctly.

Can you tell me if this code is correct?

      # ACTIONS

      self.actionFirstBut = QAction(QIcon(":/plugins/FIRST.png"), \
                  "First button", self.iface.mainWindow())
      self.actionFirstBut.setCheckable (True)
      QObject.connect(self.actionFirstBut, SIGNAL("activated()"),
self.runFirst)

      [...]


      # TOOLBAR

      self.topToolbar = self.iface.addToolBar ( "test" )
      self.topToolbar.setObjectName ("test")


      # TOOLBUTTON

      self.civiciToolButton = QToolButton()
      self.civiciToolButton.setPopupMode( QToolButton.InstantPopup )
      self.civiciToolButton.setAutoRaise( True )
      self.civiciToolButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
      self.civiciToolButton.setCheckable( True )

      self.civiciToolButton.addAction( self.actionFirstBut )
      self.civiciToolButton.addAction( self.actionSecondBut )
      self.civiciToolButton.addAction( self.actionThirdButton )

      self.civiciToolButton.setDefaultAction( self.actionFirstBut )

      self.topToolbar.addWidget( self.civiciToolButton )




More information about the PyQt mailing list