[Qt-interest] QDesignerCustomWidgetInterface and ui files
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Tue May 31 15:27:59 CEST 2011
> From: Nick Davidson
> Sent: Tuesday, 31 May 2011 20:39 PM
>
> Dear List,
>
> We are using Qt 4.6.3 on Debian Squeeze and currently investigating
> using custom widgets compiled in to libraries and exposed to Designer
> via the plugin interface.
>
> The domXml documentation
> (http://doc.qt.nokia.com/4.6/designer-creating-custom-widgets.
> html#notes
> -on-the-function) is unclear on what it is actually necessary
> to return
> in order to get a plugin to display properly in Designer / Creator and
> if you can lay out a custom widget and it's children in a Form file
> (*.ui) or not.
>
>
> I have a working plugin but in order to make it display
> correctly I had
> to move the contents of the customwidget.ui file in to the domXml()
> function and return it as one massive string.
>
> If I try and just specify the geometry we loose all the custom styling
> and constraints we've applied and if I follow the examples and add the
> <customwidgets> <customwidget> hirarchy we don't get anything
> displayed
> at all.
>
> Is there a way of specifying the ui file to include in the <ui> tag or
> does the whole thing have to be designated either in C++ like the
> analogue clock example or as a string in domXML? I feel like we've got
> something wrong in our pro files.
>
> An example project tree is available at
> https://gitorious.org/qtcustomwidget/qtcustomwidget/trees/master
> And the domXML we are currently exporting at:
>
https://gitorious.org/qtcustomwidget/qtcustomwidget/blobs/master/plugin/pred
ictorwidgetplugin.cpp#line62
>
> Regards,
Hi Nick,
We have over 70 custom widgets - most have ui files. In these cases, the
widget constructor does exactly the same as our forms:
ui.setupUi(this)
(Note some Qt users prefer ui pointers, etc.)
All of the widget plugin object's domXml have:
return "<widget class=\"TCheckBoxList\" name=\"checkBoxList\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>100</width>\n"
" <height>100</height>\n"
" </rect>\n"
" </property>\n"
"</widget>\n";
During the drag, the widget just appears as a small square, which is fine by
us. Once dropped, the widget appears and behaves correctly.
In the .pro file, the widgets and forms just refer to the ui files, and uic
is called on them.
I did try setting up a base class for the widget plugin objects, but it
didn't work - it seems the interface has to be declared on the plugin object
itself, not on an ancestor. The symptoms sound like yours - when dropped,
only a plain widget was displayed.
Hope that helps,
Tony
More information about the Qt-interest-old
mailing list