When building GIS applications with QGIS C++ and Qt, giving users direct access to vector layer properties is a must. The QgsVectorLayerProperties dialog in QGIS provides a familiar and powerful interface for managing symbology, metadata, attribute tables, labeling, and much more.
In this article, we’ll walk through how to open and manage the vector layer properties dialog from within your own Qt-based QGIS application — including restoring the last opened tab or navigating to a specific settings page.
Why Show Vector Layer Properties Programmatically?
Instead of re-creating complex settings panels from scratch, developers can leverage QGIS’s built-in properties dialog. This ensures:
- A consistent user experience with QGIS Desktop
- Full access to QGIS’s robust layer configuration options
- Faster development time
- Ability to add custom configuration pages for domain-specific workflows
Step-by-Step Implementation in QGIS C++
Below is a working code snippet that opens the vector layer properties dialog in a Qt-based QGIS application.
case Qgis::LayerType::Vector:
{
// Cast to QgsVectorLayer
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>(mapLayer);
// Create the Vector Layer Properties dialog
QgsVectorLayerProperties *vectorLayerPropertiesDialog =
new QgsVectorLayerProperties(mMapCanvas, visibleMessageBar(), vlayer, this);
// Add additional configuration pages (if available)
for (const QgsMapLayerConfigWidgetFactory *factory : std::as_const(providerFactories))
{
vectorLayerPropertiesDialog->addPropertiesPageFactory(factory);
}
// Open a specific page if provided, otherwise restore last opened page
if (!page.isEmpty())
vectorLayerPropertiesDialog->setCurrentPage(page);
else
vectorLayerPropertiesDialog->restoreLastPage();
// Execute the dialog
if (vectorLayerPropertiesDialog->exec())
{
// Optional: refresh UI or reapply layer-related actions
}
// Clean up memory
delete vectorLayerPropertiesDialog;
break;
}
Code Breakdown
1️⃣ Checking Layer Type
We first ensure the selected layer is a vector layer before proceeding:
case Qgis::LayerType::Vector:
2️⃣ Creating the Properties Dialog
The QgsVectorLayerProperties
dialog is the same one used in QGIS Desktop when you right-click a vector layer and choose Properties:
new QgsVectorLayerProperties(mMapCanvas, visibleMessageBar(), vlayer, this);
3️⃣ Adding Custom Pages
Developers can extend the dialog by adding custom property page factories:
vectorLayerPropertiesDialog->addPropertiesPageFactory(factory);
4️⃣ Restoring or Selecting a Page
You can restore the last opened tab or jump directly to a specific tab like Symbology or Metadata:
vectorLayerPropertiesDialog->restoreLastPage();
vectorLayerPropertiesDialog->setCurrentPage(page);
5️⃣ Running the Dialog
The dialog is executed modally:
vectorLayerPropertiesDialog->exec();
If the user confirms changes, you can refresh your UI accordingly.
6️⃣ Cleaning Up
Since the dialog is allocated dynamically, always delete it after use:
delete vectorLayerPropertiesDialog;
Benefits of This Approach
✅ Consistency — Matches QGIS Desktop UI, reducing training needs
✅ Full Functionality — Access to all layer settings, including advanced features
✅ Extensibility — Add your own configuration tabs for specialized tools
✅ Time Savings — Avoids re-implementing complex UI logic
Conclusion

By leveraging QgsVectorLayerProperties in your QGIS C++ application, you can deliver a powerful, feature-rich interface for managing vector layers without reinventing the wheel. This method ensures users get the same level of control they expect from QGIS Desktop, while giving you the flexibility to integrate domain-specific enhancements.
If you’re building GIS tools, radar display systems, or mission planning software, this technique can significantly improve your development speed and user experience.
👉 Contact Manya Technologies – business@manyatechnologies.com