PDA

View Full Version : custom widget: exposing properties of subwidgets



snydesc
13th February 2012, 18:24
I have a custom container widget that I designed and created a plugin for it without any issues. The widget I have contains subwidgets that are only visible to the widget that gets shown in the designer. I want to have a Q_Property defined in one of the subwidgets and have it show up in the designer, however this is becoming quite the challenge. Does anyone know how to do this?

Here is small example of what I am trying to do:



class QDESIGNER_WIDGET_EXPORT Container : public QWidget
{
Q_OBJECT

public:
Container(QWidget *aParent = 0);
~Container();

void addPart(QWidget *aPart, QString const &aTitle);
private:
QList<QWidget*> mPartList;
};




class Q_DECL_EXPORT ContainerPart : public QWidget
{
Q_OBJECT
Q_PROPERTY(QString pageTitle READ getPageTitle WRITE setPageTitle)

public:
ContainerPart(QWidget *aPage, QWidget *aParent = 0);
~ContainerPart();

QString getPageTitle();
void setPageTitle(QString const &aTitle);

protected:
QLabel *mTitle;
QWidget *mPart;

};


Basically I will have a container that contains multiple Parts. I want a way in the designer to set the title for each of the parts. Note that I have no problem displaying the parts in the designer, I just can't get the property in "ContainerPart" to show. I am thinking it may be due to the Q_DECL_EXPORT.

Added after 10 minutes:

I am wondering if the problem is with the plugin I wrote. Since this is a container I had to use the QDesignerContainerExtension and the insertWidget function that needs to be implemented requires a QWidget and not a "ContainerPart". Since it only knows what a QWidget is I think that is why it is not displaying the property.