3

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.

1 Answer 1

4

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])

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.