Results 1 to 8 of 8

Thread: Apply Layout to custom widget plugin container

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2014
    Posts
    5
    Thanks
    2

    Default 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!


    Layout.PNG

    Here are some code snippets of the plugin class. If I left out any important information, please let me know.

    Qt Code:
    1. QWidget *ResultFramePlugin::createWidget(QWidget *parent)
    2. {
    3. return new ResultFrame(parent);
    4. }
    5.  
    6. bool ResultFramePlugin::isContainer() const
    7. {
    8. return true;
    9. }
    10.  
    11. QString ResultFramePlugin::domXml() const
    12. {
    13. return "<widget class=\"ResultFrame\" name=\"ResultFrame\">\n"
    14. " <property name=\"geometry\">\n"
    15. " <rect>\n"
    16. " <x>0</x>\n"
    17. " <y>0</y>\n"
    18. " <width>50</width>\n"
    19. " <height>50</height>\n"
    20. " </rect>\n"
    21. " </property>\n"
    22. " <property name=\"toolTip\" >\n"
    23. " <string>Frame</string>\n"
    24. " </property>\n"
    25. " <property name=\"whatsThis\" >\n"
    26. " <string>Frame widget</string>\n"
    27. " </property>\n"
    28. "</widget>\n";
    29. }
    To copy to clipboard, switch view to plain text mode 

    Thanks for any help,
    Alex

    Edit: Maybe I should mention the Qt version: I am using Qt5.3.1 and qtcreator 3.2.81.
    Last edited by Alex87; 27th July 2014 at 17:30.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Apply Layout to custom widget plugin container

    Hmm, looks right. Is the isContainer() method called?

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Alex87 (27th July 2014)

Similar Threads

  1. Replies: 2
    Last Post: 27th July 2011, 15:49
  2. Replies: 1
    Last Post: 23rd June 2011, 23:09
  3. Custom Container widget plugin help needed
    By JohnKustrin in forum Newbie
    Replies: 1
    Last Post: 14th May 2010, 10:01
  4. Problem with custom container widget
    By MrGarbage in forum Qt Tools
    Replies: 4
    Last Post: 25th August 2007, 03:37
  5. Replies: 4
    Last Post: 9th August 2007, 08:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.