Steps to disable Python

I am developing python plugins for QGIS . I am listing all database connections in the menu bar using the 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)

      

Under certain conditions, the if , I want to do one of the following is disabled in the menu bar.

Example: in the Database menu we have two listed database connections:

Database
  -- localhost
  -- 192.168.5.6

      

I want some of them to be disabled depending on the specific state. I have tried a.setCheckable(false)

without success.

+3


source to share


1 answer


If I understood correctly, you need:

a.setEnabled(True/False)

      



Here is some additional information about the item QAction

: QT Documentation: QAction

+5


source







All Articles