TransWikia.com

How to select a specific tab at opening in the QGIS options dialog?

Geographic Information Systems Asked by J. Monticolo on June 10, 2021

I want to open QGIS options dialog (menu Settings > Options) programmatically and focus a specific tab.

I saw the QgisInterface.showOptionsDialog class method description :

virtual void QgisInterface::showOptionsDialog ( QWidget * parent =
nullptr, const QString & currentPage = QString() )

Opens the options dialog.

The currentPage argument can be used to force the dialog to open at a
specific page.

but I don’t know which value enter for currentPage.

One Answer

With QGIS code source investigation, the currentPage values are the Qt object names of the options dialog page widgets.

So, the QGIS options dialog can be opened at specific tabs with :

page_names = [
    "mOptionsPageGeneral",
    "mOptionsPageSystem",
    "mOptionsPageCRS",
    "mOptionsPageDataSources",
    "mOptionsPageRendering",
    "mOptionsPageMapCanvas",
    "mOptionsPageMapTools",
    "mOptionsPageColors",
    "mOptionsPageDigitizing",
    "mOptionsPageComposer",
    "mOptionsPageGDAL",
    "mOptionsPageVariables",
    "mOptionsPageAuth",
    "mOptionsPageNetwork",
    "mOptionsPageLocatorSettings",
    "mOptionsPagePageSettingsEditor",
    "mOptionsPageAcceleration",
]
# to open options dialog on the general tab
iface.showOptionsDialog(currentPage=page_names[0])

Correct answer by J. Monticolo on June 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP