Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I put complex pointer data as property into qt plugin xml file

I have implemented a widget in Qt like below:

class MyWidget : public QWidget
{
    Q_OBJECT
    Q_PROPERTY( bool BooVal READ getBoolVal WRITE setBoolVal)
    Q_PROPERTY( MyPointer* PointerData READ getPointer WRITE setPointer);

    ...
}

I want to use it in QtDesinger. Therefore I implemented QDesignerCustomWidgetInterface interface like below:

class MyPlugin : public QObject, public QDesignerCustomWidgetInterface
{

    ...
} 

QWidget *MyPlugin::createWidget( QWidget *parent )   
{    
    return new MyWidget(parent);
}

But in QtDesigner property window I can't set complex data like Q_PROPERTY(MyPointer* PointerData ...). Some Qt widget like QTreeWidget can set complex pointer data in QtDesigner through custom interface. e.g. in QTreeWidget when I set parent node and it's children, sth like below appears in .ui file

<widget class="QTreeWidget" name="treeWidget">
  <item>
    <property name="text">
       <string>1</string>
    </property>
    <item>
       <property name="text">
           <string>1-1</string>
       </property>
    </item>
  </item>
</widget>

In fact I want to create a plugin like QTreeWidget and set complex data like QTreeWidgetItem* through QtDesinger.

like image 275
Siami Avatar asked Nov 12 '22 17:11

Siami


1 Answers

Do you want to save a subclass of QTreeWidget in UI xml form? you can use

void QAbstractFormBuilder::save(QIODevice * device, QWidget * widget) 

function of void QAbstractFormBuilder class or QFormBuilder class.

like image 168
hassan deldar Avatar answered Nov 15 '22 11:11

hassan deldar