Results 1 to 4 of 4

Thread: QGridLayout size not the same the second time

  1. #1
    Join Date
    Sep 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGridLayout size not the same the second time

    hello community, i have a QGridLayout who i fill with some custom widget.

    1- the first time i fill it i ask the hight and the answer is the right one, and is shown as i specked with these function, no problem at all.

    Qt Code:
    1. this->yearLayout->getGrid()->sizeHint().height();
    To copy to clipboard, switch view to plain text mode 

    2- then i erase the content of the gridlayout these way:

    Qt Code:
    1. while(this->pictureLayout->count() > 0)
    2. {
    3. QWidget* widget = this->pictureLayout->itemAt(0)->widget();
    4. this->pictureLayout->removeWidget( widget );
    5. delete widget;
    6. }
    To copy to clipboard, switch view to plain text mode 

    3-if i fill again the grid with the same function of step 1 and ask the hight the answer is always "18" but the grid is shown as i specked with all the widget on every cell.
    4- Never again i get the right hight value, just the first time i fill my grid.

    i don´t know if is something these cleaning function do or if it set the grid to do something i don´t want. These way is cleaned perfect but i can´t ever get the height no more, and is what i want.

    if any one can help me i will appreciate it.

    hugs

  2. #2
    Join Date
    Jul 2011
    Location
    Italy
    Posts
    24
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QGridLayout size not the same the second time

    Try to set the sizeConstraint to the layout you are removing and adding items:
    Qt Code:
    1. this->pictureLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGridLayout size not the same the second time

    I have tried all "::Set*" and no different results.

    If i comment the grid cleaning function i get the result that i want but widgets are puts one over others, so the conclusion is that the not desire behavior is produce in these function.

    And if i uncommented the result is the same:

    1- first time (empty greed) it fill and hight is right (over 600)
    2- second time after cleaning function (to clean first time widgets) the grid is fill properly but hight is not right (only 18 and must be at least the same as the fist time)
    3- and so on

    so the conclusion is that something is wrong with my cleaning function

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

    Default Re: QGridLayout size not the same the second time

    Please provide a minimal compilable example reproducing the problem.
    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. QGridLayout: force all widget to the same size
    By Spooky in forum Qt Programming
    Replies: 2
    Last Post: 23rd March 2011, 13:58
  2. Replies: 0
    Last Post: 12th August 2010, 16:05
  3. Set size when insert a QWidget into a QGridLayout
    By Tondog in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2010, 06:35
  4. Adjusting Widget size in a QGridLayout
    By Max Yaffe in forum Qt Programming
    Replies: 1
    Last Post: 30th July 2007, 22:03
  5. Margin size of QGridLayout
    By Cainofnod in forum Qt Programming
    Replies: 1
    Last Post: 13th January 2007, 08:59

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
  •  
Qt is a trademark of The Qt Company.