4

I am developing python plugins for QGIS. I am listing all the database connections to menu bar, using following code:

 for key in sorted( self.actionsDb.iterkeys(), key=lambda x: x.lower() ):
                    a = self.actionsDb[key]
                    self.menuDb.addAction(a)
                    a.setCheckable(True)
                    self.connect(a, SIGNAL("triggered(bool)"), self.dbConnectSlot)

On certain 'if' condition, I want to make one of the actions disabled in the menu bar.

Example: under Database menu, we have two listed database connections:

Database
  -- localhost
  -- 192.168.5.6

I want to make some of them disabled depending on specific condition. I've tried a.setCheckable(false) with no success.

bezmax
  • 25,562
  • 10
  • 53
  • 84
poonam
  • 748
  • 4
  • 19
  • 40

1 Answers1

6

If I understood you right, what you need is:

a.setEnabled(True/False)

Here's some additional info on QAction element: QT Documentation:QAction

bezmax
  • 25,562
  • 10
  • 53
  • 84