Compiling Qt Property Browser as a Shared Library and Creating a Qt Designer Plugin

The qtpropertybrowser module from the Qt Solutions Archive provides a flexible property editing system. To integrate this component into larger applications efficiently, it is often necessary to build it as a shared library and expose its widgets through the Qt Designer environment.

Building the Shared Library

The project provides a batch script for initial configuration. To produce a shared library instead of static archives, pass the -library flag:

configure.bat -library
qmake
nmake

Alternatively, for developers prefering the Visual Studio IDE, generate the solution file using the platform-specific template flag:

qmake qtpropertybrowser.pro
qmake -tp vc -r

This generates a .sln file alongside individual project files. Upon opening the solution in Visual Studio, you may encounter a missing symbol definition during compilation. Navigate to the project properties under C/C++ > Preprocessor > Preprocessor Definitions and locate QT_QTPROPERTYBROWSER_IMPORT. Replace it with QT_QTPROPERTYBROWSER_EXPORT to properly export symbols from the dynamic library.

Integrating Assistance Documentation

The repository ships with a .qhp source file rather than a compiled .qch archive. You can bridge this gap by invoking the Qt Help Generator utility:

cd doc/html
qhelpgenerator qtpropertybrowser.qhp -o qtpropertybrowser.qch
assistant -register qtpropertybrowser.qch

Once registered, open Assistant, navigate to the Search tab, and query QtProperty to verify successful indexing.

Developing the Qt Designer Plugin

With the runtime library ready, the next step is extending Qt Designer to recognize the custom widgets. This requires implementing the designer extension interface.

#include <QDesignerCustomWidgetInterface>
#include <QWidget>

class ExtendedPropertyUI : public QObject, public QDesignerCustomWidgetInterface {
    Q_OBJECT
    Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
    explicit ExtendedPropertyUI(QObject *parent = nullptr) : QObject(parent) {}
    QString name() const override { return QStringLiteral("ExtendedPropertyBrowser"); }
    QString group() const override { return QStringLiteral("Property Editors[Extended]"); }
    QIcon icon() const override { return QIcon(); }
    bool isContainer() const override { return false; }
    QString includeFile() const override { return QStringLiteral("QtSolutions_PropertyBrowser-header/qtreepropertybrowser.h"); }
    QWidget *createWidget(QWidget *parent) override {
        return new ExtendedPropertyBrowser(parent);
    }
};

To register multiple components within a single plugin, aggregate these interfaces into a collection manager:

#include <QList>
#include <memory>
#include <vector>

class DesignerWidgetRegistry {
public:
    explicit DesignerWidgetRegistry(QObject *parent = nullptr) : QObject(parent) {
        m_registeredExtensions.push_back(std::make_unique<ExtendedPropertyUI>());
        m_registeredExtensions.push_back(std::make_unique<ButtonBrowserUI>());
        m_registeredExtensions.push_back(std::make_unique<GroupBoxBrowserUI>());
    }
    const QList<QObject*> &getExtensions() const noexcept {
        QList<QObject*> result;
        for (const auto &ext : m_registeredExtensions) {
            result.append(ext.get());
        }
        return result;
    }
private:
    std::vector<std::unique_ptr<QObject>> m_registeredExtensions;
};

Compile the resulting plugin DLL and copy it into the Designer extensions directory. The exact path typically resides at <Qt_Installation_Path>/plugins/designer.

Relaunch the design environment. The newly registered widgets will appear in the Widget Box panel under the designated group category.

Cross-Version Architecture Notes

While the original sourcebase targets legacy Qt 4.x releases, modern builds can integrate the updated qtpropertybrowser source. A primary architectural divergence exists in the underlying view implementation: earlier revisions rely on QTreeView, whereas updated branches utilize QTreeWidget. Adjusting export macros for all target classes remains necessary when porting between major release cycles. Further integration details depend on specific appplication requirements.

Tags: Qt Designer Dynamic Libraries C++ Qt Solutions Custom Widgets

Posted on Sat, 24 Oct 2026 16:12:25 +0000 by Renlok