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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With