Results 1 to 7 of 7

Thread: Can't change QHBoxLayout geometry

  1. #1
    Join Date
    Oct 2009
    Posts
    28
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Can't change QHBoxLayout geometry

    Hello people,

    I have a problem (very easy it seems) that I can't find the solution.
    I've a widget with QHBoxLayout in it and I would like to change the geometry of the layout. I thought it was enough by using setGeometry(), but it doesn't work.
    I have also notice that x and y components of the layout are 0.

    I hope you can help me.

    Regards.

  2. #2
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't change QHBoxLayout geometry

    Hi
    Code please !

  3. #3
    Join Date
    Oct 2009
    Posts
    28
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't change QHBoxLayout geometry

    Hello and thaks for your answer.

    I'm sorry, but I thought It wasn't necessary to include the code for changing the geometry of a layout.

    Here is my code

    Qt Code:
    1. void CWGraficaSimple::resizeEvent(QResizeEvent *event)
    2. {
    3.  
    4. QRect hboxRect = ui.hboxLayout->geometry();
    5. int difVer = event->size().height() - event->oldSize().height();
    6.  
    7. ui.hboxLayout->setGeometry( QRect(hboxRect.x(), hboxRect.y() + difVer, hboxRect.width(), hboxRect.height()));
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    I just want to "move" the y cordenate of the layout.

    Thanks a lot again.

  4. #4
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't change QHBoxLayout geometry

    Perhaps your layout doesn't have any related QWidget to provide the geometry.

    You can try this:
    Qt Code:
    1. QWidget* layoutWidget = new QWidget();
    2. layoutWidget.setLayout(ui.hboxLayout);
    3. layoutWidget.setGeometry(100,100,200,200);
    To copy to clipboard, switch view to plain text mode 
    It's not the goodbye that hurts,but the flashback that follow.

  5. The following user says thank you to MorrisLiang for this useful post:

    gutiory (17th June 2010)

  6. #5
    Join Date
    Oct 2009
    Posts
    28
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't change QHBoxLayout geometry

    Thanks a lot MorrisLang!!!!.
    You were completly wright. I just added a widget and put a widget into. After that I set the layout inside the widget and I only have to move the widget.

    Thanks again.

    Regards.

  7. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't change QHBoxLayout geometry

    Layouts act like containers for widgets and have their own intelligence how to set widgets.
    You should use layouts geaometry, instead the widgets geometry as mentioned above.

  8. #7
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't change QHBoxLayout geometry

    Quote Originally Posted by aamer4yu View Post
    Layouts act like containers for widgets and have their own intelligence how to set widgets.
    You should use layouts geaometry, instead the widgets geometry as mentioned above.
    No,I don't think so.According to the doc,"The widget will get an event of type QEvent::LayoutRequest when the layout needs to be recalculated".Layout relies on a QWidget to calculate the size.
    It's not the goodbye that hurts,but the flashback that follow.

Similar Threads

  1. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  2. GraphicsView: Notifying geometry change to parent group
    By Gopala Krishna in forum Qt Programming
    Replies: 8
    Last Post: 12th August 2007, 12:04
  3. zero'ing margin in a qhboxlayout
    By illuzioner in forum Qt Programming
    Replies: 3
    Last Post: 2nd July 2007, 10:54
  4. QHBoxLayout Problem
    By Seema Rao in forum Qt Programming
    Replies: 5
    Last Post: 29th April 2006, 15:51
  5. Replies: 3
    Last Post: 19th April 2006, 20:53

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.