Results 1 to 7 of 7

Thread: Promoting the parent QWidget of a QWidget form

  1. #1
    Join Date
    Jun 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Promoting the parent QWidget of a QWidget form

    Hi,

    I am current creating a custom widget of my own, derived from QWidget. I am trying to create the UI elements for it in QT Designer but I couldn't promote the topmost QWidget at all (I have to add another QWidget and promote that instead). Is it possible to promote the main/topmost QWidget to my custom widget?

    Regards,
    Kun

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

    Default Re: Promoting the parent QWidget of a QWidget form

    It wouldn't do you any good. Just setup the component on an appropriate subclass of QWidget when calling setupUi() in your code.
    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.


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

    sedi (19th July 2013)

  4. #3
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Promoting the parent QWidget of a QWidget form

    I don't agree with the answer to this question !

    It's perfectly valid to want promote the top most widget, scenario:

    We are designing several forms/dialogs and want all of then inherit from the basicFormDialog where we can insert all the common code and settings.

    I'm looking for this functionality too and hope that it can be enabled in future versions of QTCreator !

    Also the promoting idea should be usable with layouts too !
    Last edited by mingodad; 16th April 2010 at 10:32.

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

    Default Re: Promoting the parent QWidget of a QWidget form

    Quote Originally Posted by mingodad View Post
    I don't agree with the answer to this question !

    It's perfectly valid to want promote the top most widget, scenario:

    We are designing several forms/dialogs and want all of then inherit from the basicFormDialog where we can insert all the common code and settings.

    I'm looking for this functionality too and hope that it can be enabled in future versions of QTCreator !
    Promoting a widget doesn't yield any benefits other than forcing uic to generate code for the promoted widget instead of its superclass. Bearing the fact that uic doesn't create the top-most widget, promoting it doesn't make any sense, the code generated by uic would be identical with the only exception that setupUi() would have a different argument type which would give no additional value considering the presence of inheritance in C++ where you can pass a subclass to a function that expects a superclass.

    Also the promoting idea should be usable with layouts too !
    I'm not sure how promoting a layout would work... I could understand a layout plugin but promoting a layout...?

  6. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,460
    Thanked 271 Times in 266 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Promoting the parent QWidget of a QWidget form

    Quote Originally Posted by mingodad View Post
    I don't agree with the answer to this question !

    It's perfectly valid to want promote the top most widget, scenario:

    We are designing several forms/dialogs and want all of then inherit from the basicFormDialog where we can insert all the common code and settings.

    I'm looking for this functionality too and hope that it can be enabled in future versions of QTCreator !

    Also the promoting idea should be usable with layouts too !
    Just create plugin for Designer with Yours basicFormDialog and that's all.

  7. The following user says thank you to Lesiok for this useful post:

    sedi (19th July 2013)

  8. #6
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Promoting the parent QWidget of a QWidget form

    That is not so easy or the most usefull way to do it.

    Writing a plugin isn't so easy and there is the problem of different compilers platforms.

    I don't understand what it means :
    -----
    Promoting a widget doesn't yield any benefits other than forcing uic to generate code for the promoted widget instead of its superclass. Bearing the fact that uic doesn't create the top-most widget, promoting it doesn't make any sense, the code generated by uic would be identical with the only exception that setupUi() would have a different argument type which would give no additional value considering the presence of inheritance in C++ where you can pass a subclass to a function that expects a superclass.
    ----

    Look at what I expect:
    Attached Files Attached Files
    Last edited by mingodad; 16th April 2010 at 12:34.

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

    Default Re: Promoting the parent QWidget of a QWidget form

    FormBase is derived from QWidget so you don't need to promote the form to FormBase, it can be QWidget-based without losing any functionality.

    Promoting the layout doesn't make much sense as you wouldn't be able to use the added functionality in Designer anyway so it's easier to leave blank space on the form and then place the new layout in code. Otherwise you will have WYSINWYG (what you see is not what you get) semantics. You have to accept the fact you can't do everything with point & click.

    Next time please attach individual files as files or as an archive of files, not as a text file containing the offending content of your post.

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

    sedi (19th July 2013)

Similar Threads

  1. How can I access public variable parent Form
    By validator in forum Qt Programming
    Replies: 14
    Last Post: 18th December 2008, 21:12
  2. Non-transparent QWidget on semi-transparent parent
    By EuroElessar in forum Qt Programming
    Replies: 0
    Last Post: 29th August 2008, 16:20
  3. Enable QWidget child while parent disabled
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 30th May 2008, 10:53
  4. Problem with Parent QWidget and Buttons not working
    By VireX in forum Qt Programming
    Replies: 7
    Last Post: 11th May 2007, 22:24
  5. Replies: 1
    Last Post: 28th July 2006, 14:10

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.