Results 1 to 8 of 8

Thread: Creating a custom layout for QWidget

  1. #1
    Join Date
    May 2015
    Location
    India
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Creating a custom layout for QWidget

    How can I place widgets relatively to each other in a QWidget without using any layout widget (like QGridLayout, QLayout etc) in Qt?
    Can i use grabWidget() and paint widgets to QWidget, using information from the QRect() of other widgets? If yes, how?

  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: Creating a custom layout for QWidget

    Why you don't want to use layouts?
    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. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,198
    Thanks
    237
    Thanked 668 Times in 658 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Creating a custom layout for QWidget

    Can i use grabWidget() and paint widgets to QWidget, using information from the QRect() of other widgets? If yes, how?
    Yes, of course you can do that, and you'll get a QWidget with pictures of other widgets in it. They aren't QWidgets, so your users won't be able to interact with them. Why on earth would you want to do something like that?

    I suspect that you are not correctly designing your layouts, which is why you are trying to reinvent the wheel.

  4. #4
    Join Date
    May 2015
    Location
    India
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating a custom layout for QWidget

    The reason is historical. Just tell me if you can do that. I want users to interact with the widgets.


    Added after 5 minutes:


    Because I don't want to put my widgets in a grid-type manner. Can i do that?

    Because I don't want to put my widgets in a grid-type manner or horizontal or vertical manner. Can i do that?
    Last edited by prajain; 14th May 2015 at 06:57.

  5. #5
    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: Creating a custom layout for QWidget

    Quote Originally Posted by prajain View Post
    The reason is historical. Just tell me if you can do that. I want users to interact with the widgets.
    You can postion all your widgets manually if you want. But that's usually a bad idea.

    Because I don't want to put my widgets in a grid-type manner. Can i do that?

    Because I don't want to put my widgets in a grid-type manner or horizontal or vertical manner. Can i do that?
    What manner do you want to put your widgets in then?
    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
    May 2015
    Location
    India
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating a custom layout for QWidget

    I wanted to put the widgets relative to other widgets. For example, I can place the widget either right or left and either top or bottom of a widget. Something like that.

  7. #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: Creating a custom layout for QWidget

    You can do that with existing layouts or you can implement a custom layout to do this.
    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.


  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,198
    Thanks
    237
    Thanked 668 Times in 658 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Creating a custom layout for QWidget

    I wanted to put the widgets relative to other widgets. For example, I can place the widget either right or left and either top or bottom of a widget. Something like that.
    It sounds like you want something like "glue", which is used in another layout system the details of which I don't remember. "Interviews", maybe?

    You can do this with grid, horizontal, vertical or a combination of layouts in a hierarchy. If you want to do this dynamically at runtime, then you need a way to specify the locations of widgets relative to each other, and build up the layouts to reflect that relationship. So if you have two widgets that are located top and bottom relative to each other, you create a a vertical layout, insert the top widget then the bottom widget.

    If you don't want the widgets to expand their sizes or spacings as the container widget resizes, then insert horizontal or vertical spacers into the layouts.

Similar Threads

  1. Replies: 2
    Last Post: 24th September 2014, 02:02
  2. creating QWidget Plugins
    By Spooky in forum Qt Programming
    Replies: 15
    Last Post: 26th January 2011, 09:58
  3. QWidget layout problems
    By MarkoSan in forum Newbie
    Replies: 3
    Last Post: 12th January 2010, 11:23
  4. layout QLabel and QWidget
    By franco.amato in forum Qt Programming
    Replies: 1
    Last Post: 8th January 2010, 12:53
  5. Creating a square sized widget in a layout
    By cboles in forum Qt Programming
    Replies: 5
    Last Post: 23rd September 2008, 00:38

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.