Created custom designer plugin similar to Container Extension Example. After some modifications with QDesignerCustomWidgetInterface, QDesignerContainerExtension and QExtensionFactory classes and adding following methods to my container:
Q_OBJECT
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex)
Q_PROPERTY(QString pageTitle READ pageTitle WRITE setPageTitle STORED
false)
public:
int count() const { return mTreeWidget->topLevelItemCount(); }
public slots:
void setCurrentIndex(int index);
void insertPage
(int index,
QWidget *widget
);
void removePage(int index);
int currentIndex() const { return mTreeWidget->currentIndex().row(); }
void setPageTitle
(QString const &newTitle
);
protected:
PageButton *categoryButton(int index) const;
signals:
void currentIndexChanged(int index);
void pageTitleChanged
(const QString &title
);
Q_OBJECT
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex)
Q_PROPERTY(QString pageTitle READ pageTitle WRITE setPageTitle STORED false)
public:
WidgetBox(QWidget *parent = 0);
int count() const { return mTreeWidget->topLevelItemCount(); }
QWidget* widget(int index) const;
QString pageTitle() const;
public slots:
void setCurrentIndex(int index);
void addPage(QWidget *widget);
void insertPage(int index, QWidget *widget);
void removePage(int index);
int currentIndex() const { return mTreeWidget->currentIndex().row(); }
void setPageTitle(QString const &newTitle);
protected:
QTreeWidgetItem * addCategory(QString pageName);
QTreeWidgetItem * insertCategory(int index, QString pageName);
PageButton *categoryButton(int index) const;
void createContainerWidget(QTreeWidgetItem* page, QWidget *widget);
void createCategoryButton(QTreeWidgetItem* page, QString pageName);
signals:
void currentIndexChanged(int index);
void pageTitleChanged(const QString &title);
To copy to clipboard, switch view to plain text mode
Qt designer started to crash on start with my plugin. Any way do debug plugin (extension) and found the cause? Plugin build in release mode with same Qt and VS C++ versions as Qt Designer and Creator - Based on Qt 5.5.1 (MSVC 2013, 32 bit).
Partial solution added after 18 minutes:
So method is following: commented out extension and factory classes - still crashes, sequentaly commented/uncommented methods in my widget class: problem appears in
Q_PROPERTY(QString pageTitle READ pageTitle WRITE setPageTitle STORED
false)
Q_PROPERTY(QString pageTitle READ pageTitle WRITE setPageTitle STORED false)
To copy to clipboard, switch view to plain text mode
and methods pageTitle and setPageTitle for current page when no pages available. Need think what to set/output here when no pages were added. Or add at least 1 page by default.
Now Qt Designer crashes on adding widget to a form. Will continue searching the cause.
Added after 51 minutes:
Added index check to widget() method as well, works fine for now.
Bookmarks