Results 1 to 8 of 8

Thread: extend funcitionality of Designer widgets

  1. #1
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question extend funcitionality of Designer widgets

    Hi all,

    after I setup a gui with Qt designer I want to add a method to some of the used widget.

    eg.
    having a QListWidget StList to which I want to add a filter. The filter will be selected from a QComboBox state.

    I think the "normal" aproach would be to create a new class myListWidget which base class is QListWidget and implemet a slot FilterChange which act accordingly.

    But if i do so I have no benefit from the designer as long I do not provide a plugin for this widget. To write a plugin for onetime use seems not to be a clever appoach.



    So what to do ??

    Thanks
    dexli

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: extend funcitionality of Designer widgets

    But if i do so I have no benefit from the designer as long I do not provide a plugin for this widget.
    You'll have the benefit - you can visualize the layout of your widgets. That's why I'm using the designer - application logic should be separated from the application's look - I use designer to design the user interface, the way application should look, not how it should behave.
    If you feel that you can reuse your QListWidget subclass in the future, then why not creating a plugin.
    after I setup a gui with Qt designer I want to add a method to some of the used widget.
    After I setup a gui with Qt designer, I switch to code editor in order to implement the functionality ( add methods to some of the used widgets ).

  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: extend funcitionality of Designer widgets

    Or, you can perform the inheritance step offline, then use Designer's promotion feature to include your custom widget in the layout. It won't display any custom functionality like signals or slots you might have implemented, but it'll appear in the layout and the generated code will use the correct class.

  4. #4
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: extend funcitionality of Designer widgets

    Hi,
    sorry maybe I don't make things clear enough.

    As far as I understud if I setup a new class which inherit from a widget class I have to write a plugin for designer to use this class in the designer. This is only efficient if you reuse this class serveral times. (not ony onetime)

    Quote Originally Posted by stampede View Post
    After I setup a gui with Qt designer, I switch to code editor in order to implement the functionality ( add methods to some of the used widgets ).
    And if you have to change the layout all the work is gone because this file is overwritten by the designer. So that seem not to be a good choice to me.

    Quote Originally Posted by SixDegrees View Post
    Or, you can perform the inheritance step offline, then use Designer's promotion feature to include your custom widget in the layout. It won't display any custom functionality like signals or slots you might have implemented, but it'll appear in the layout and the generated code will use the correct class.
    That sounds like it is what i'm looking for. Can you please tell me where I find a howto about this promotion feature.

    Thanks

    dexli

  5. #5
    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: extend funcitionality of Designer widgets

    Place a base class for your widget on the form and invoke the context menu on it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: extend funcitionality of Designer widgets

    Quote Originally Posted by wysota View Post
    Place a base class for your widget on the form and invoke the context menu on it.
    Thanks a lot.

    How can I mark this thread as solved ?

  7. #7
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: extend funcitionality of Designer widgets

    And if you have to change the layout all the work is gone because this file is overwritten by the designer
    Nothing is gone, because designer form is used only to manage layout, not behavior of widgets. If you want to change the layout, you just have to edit .ui file, implementation for the class (.cpp / .h ) is left untouched, only ui_*.h is automatically generated, but I don't think anyone edits this file by hand. Right click and "Promote to..." is what you are looking for.

  8. #8
    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: extend funcitionality of Designer widgets

    Quote Originally Posted by stampede View Post
    but I don't think anyone edits this file by hand
    Unfortunately lots of people do it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Promoted widgets in Qt Designer
    By martinb0820 in forum Qt Tools
    Replies: 1
    Last Post: 9th June 2010, 15:07
  2. Custom Widgets in QT DEsigner
    By amitkhanna in forum Newbie
    Replies: 3
    Last Post: 4th June 2010, 06:15
  3. Cannot drop widgets in Qt Designer 4.4.0
    By DerSchoeneBahnhof in forum Qt Tools
    Replies: 2
    Last Post: 19th June 2008, 17:18
  4. Replies: 13
    Last Post: 15th December 2006, 11:52
  5. How to create pop up widgets in designer.
    By gsQT4 in forum Qt Tools
    Replies: 1
    Last Post: 25th May 2006, 16:40

Tags for this Thread

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.