1 Attachment(s)
Apply Layout to custom widget plugin container
Hello,
I am trying to create a custom wigdet and provide it to qtcreator as a plugin. The widget is meant to be a frame, containing an icon and a title and should work as a container for other widgets. I created the widget's class + ui (ResultFrame) and the plugin class (ResultFramePlugin) as well. Everything works great so far. However, when I drag and drop the ResultFrame widget in a new project I cannot apply a layout to it. I can drag and drop other widgets to my ResultFrame widget. But the buttons for applying a layout stay disabled (see screenshot).
So my question is: Is it possible to create a custom container plugin and apply a layout in another project after dragging and dropping the plugin widget to the ui? If so, what am I supposed to do, since just returning true for isContainer() seems not to work. Maybe I must implement a sizeHint for the ResultFrame widget or something like that? I dont have any good idea what I should try and I dont know, how to figure out what I am doing wrong. So I would be thankful, if anyone can give me a hint!
Attachment 10528
Here are some code snippets of the plugin class. If I left out any important information, please let me know.
Code:
{
return new ResultFrame(parent);
}
bool ResultFramePlugin::isContainer() const
{
return true;
}
QString ResultFramePlugin
::domXml() const {
return "<widget class=\"ResultFrame\" name=\"ResultFrame\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>50</width>\n"
" <height>50</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string>Frame</string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string>Frame widget</string>\n"
" </property>\n"
"</widget>\n";
}
Thanks for any help,
Alex
Edit: Maybe I should mention the Qt version: I am using Qt5.3.1 and qtcreator 3.2.81.
Re: Apply Layout to custom widget plugin container
Hmm, looks right. Is the isContainer() method called?
Cheers,
_
Re: Apply Layout to custom widget plugin container
Hello anda_skoa,
thank you for your quick reply!
I implemented a QMessageBox inside the isContainer() method, which shows up when I open the ui-designer for the first time. So the method is called. Any other ideas, why it does not work as expected?
Thanks for your help in advance!
Re: Apply Layout to custom widget plugin container
My guess would be a bug in designer.
Cheers,
_
Re: Apply Layout to custom widget plugin container
Thank you for the input. I tried the plugin in qt-creator 3.0.1 and Qt 5.2.1, but the problem still remains . If anyone has build a container plugin, which accepts a layout, I woud be glad to know how it works.
Re: Apply Layout to custom widget plugin container
As a work around maybe using QDesignerContainerExtension? http://qt-project.org/doc/qt-5/qdesi...extension.html
In any case it would be helpful to check the issue tracking system if the problem has been reported and report it if not.
Cheers,
_
Re: Apply Layout to custom widget plugin container
I tried QDesignerContainerExtension and it works well! Thank you for pointing me in the right direction! I read http://comments.gmane.org/gmane.comp....general/35506 and it is stated, that isContainer() only works for widget, which do not include any chidren. The suggested work around is the correct way to get a layout applied.
Re: Apply Layout to custom widget plugin container
Well, the last posting in the thread suggests that it should have worked for your frame
Quote:
For a simple container like QFrame that does not have internal children, it
should be sufficient to return 'true' from
bool QDesignerCustomWidgetInterface::isContainer (). The user drops child
widgets directly onto those.
Cheers,
_