4

I am creating a plugin for Qgis 2.6 and when my plugin loads up i want to disable the visibility of some of the tool bar. I was able to set the visibility for various tool bars like

    self.iface.digitizeToolBar().setVisible(True)
    self.iface.mapNavToolToolBar().setVisible(True)
    self.iface.advancedDigitizeToolBar().setVisible(True)
    self.iface.pluginToolBar().setVisible(True)
    self.iface.layerToolBar().setVisible(True)

    self.iface.databaseToolBar().setVisible(False)
    self.iface.fileToolBar().setVisible(False)
    self.iface.helpToolBar().setVisible(False)
    self.iface.vectorToolBar().setVisible(False)
    self.iface.rasterToolBar().setVisible(False)
    self.iface.webToolBar().setVisible(False)
    self.iface.attributesToolBar().setVisible(False)

Apart from this tool bars I have other tool bars like Manage Layer, Grass, Label but I am not able to get the reference for this tool bar from the iface to set the visibility.

http://doc.qgis.org/api/classQgisInterface.html#a882199db87f1b58bd5fc9b3d5db00d28 This documentation does not expose this tool bars.

  • It will be valueable if you edit your question to explain what are you doing; and display your full source code. – dof1985 Apr 15 '15 at 21:27
3

You can do that in this way, from the QGIS Python console:

from PyQt4.QtGui import QToolBar
iface.mainWindow().findChild(QToolBar,'mLabelToolBar').setVisible(False)
iface.mainWindow().findChild(QToolBar,'mLayerToolBar').setVisible(False)

I got the tool bar names (e.g., mLabelToolBar and mLayerToolBar) from Settings->Customization...->Toolbars. Check it to know the Grass tool bar name (I don't have that one available).

  • 3
    I did it other way just in case this would be helpful to some one else using for x in iface.mainWindow().findChildren(QToolbar): print x.objectName() to get all the names of toolBar – Nikhil Murarka Apr 17 '15 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.