Alex87
27th July 2014, 17:25
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!
10528
Here are some code snippets of the plugin class. If I left out any important information, please let me know.
QWidget *ResultFramePlugin::createWidget(QWidget *parent)
{
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.
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!
10528
Here are some code snippets of the plugin class. If I left out any important information, please let me know.
QWidget *ResultFramePlugin::createWidget(QWidget *parent)
{
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.