Results 1 to 3 of 3

Thread: Custom plugin for a layout

  1. #1
    Join Date
    May 2006
    Posts
    16
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Custom plugin for a layout

    Is it possible to create a designer plugin for a custom "widget" that does not derive from QWidget? I have a custom layout class that derives from QBoxLayout, and I would like to display it in designer, just like I do with my custom widgets. The problem is that the createWidget() method of the plugin class returns a QWidget*, but the layout does not derive from QWidget.

    Thanks,
    Cristian

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Custom plugin for a layout

    Quote Originally Posted by cocheci
    Is it possible to create a designer plugin for a custom "widget" that does not derive from QWidget? I have a custom layout class that derives from QBoxLayout, and I would like to display it in designer, just like I do with my custom widgets. The problem is that the createWidget() method of the plugin class returns a QWidget*, but the layout does not derive from QWidget.
    No, it has to be QWidget. You can cheat a little though and return an empty QWidget just with your layout set (just remember the widget has to be marked as a container).

    I don't remember the exact syntax, but it's something like this:
    Qt Code:
    1. QWidget * plugin::createWidget(const QString &feature, QWidget *p){
    2. if(feature=="xxx"){
    3. QWidget *w = new QWidget(p);
    4. MyLayout *l = new MyLayout(p);
    5. w->setLayout(l);
    6. return w;
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

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

    cocheci (12th June 2006)

  4. #3
    Join Date
    May 2006
    Posts
    16
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Custom plugin for a layout

    Quote Originally Posted by wysota
    No, it has to be QWidget. You can cheat a little though and return an empty QWidget just with your layout set (just remember the widget has to be marked as a container).

    I don't remember the exact syntax, but it's something like this:
    Qt Code:
    1. QWidget * plugin::createWidget(const QString &feature, QWidget *p){
    2. if(feature=="xxx"){
    3. QWidget *w = new QWidget(p);
    4. MyLayout *l = new MyLayout(p);
    5. w->setLayout(l);
    6. return w;
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    This worked, thank you!
    Cristian

Similar Threads

  1. Testing a custom Plugin
    By maluta in forum Qt Programming
    Replies: 5
    Last Post: 31st October 2006, 16:09
  2. custom plugin designer property with out a variable?
    By high_flyer in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2006, 20:11
  3. How to initialize properties to a custom plugin widget?
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2006, 17:56
  4. Replies: 12
    Last Post: 15th February 2006, 11:46
  5. Managing widget plugin in Qt Designer
    By yellowmat in forum Newbie
    Replies: 8
    Last Post: 31st January 2006, 10:58

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.