Reputation: 810
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.
Upvotes: 5
Views: 5760
Reputation: 26122
If I understood you right, what you need is:
a.setEnabled(True/False)
Here's some additional info on QAction
element: QT Documentation:QAction
Upvotes: 8