Results 1 to 4 of 4

Thread: Set size when insert a QWidget into a QGridLayout

  1. #1
    Join Date
    Jul 2009
    Location
    Switzerland
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Set size when insert a QWidget into a QGridLayout

    Hi togehter,
    I've a QWidget which contained a QGroupBox.
    The QGroupBox contained a vertical Layout.
    Inside the QGroupBox, there's two other layouts. One is a QGridLayout.

    I insert on runtime a QWidget into my QGridLayout. The problem is, that the size wouldn't re-adjust.
    I want to have, that the layout will automatically set the size. Is that possible?


    The code how I insert a QWidget into the QGridLayout:


    Qt Code:
    1. QLineEdit* widget = new QLineEdit(this);
    2. widget->setMinimumHeight(24);
    3. widget->setMinimumWidth(50);
    4. ui.gridLayout->addWidget(widget, cntRows, cntColumns, 1, 1);
    To copy to clipboard, switch view to plain text mode 

    Thanks for help

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Set size when insert a QWidget into a QGridLayout

    What size should be automatically set? Of the layout or the containing widget? If the later call adjustSize().

  3. #3
    Join Date
    Jul 2009
    Location
    Switzerland
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Set size when insert a QWidget into a QGridLayout

    Of the layout resp. of the window if the window is to small for all the widgets inside the QGridLayout

  4. #4
    Join Date
    Jul 2009
    Location
    Switzerland
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Set size when insert a QWidget into a QGridLayout

    I think it's a timing problem. If I make a singelshot, it works. Does anyone know the problem?

    Qt Code:
    1. QTimer::singleShot(5, this, SLOT(setSize()));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 0
    Last Post: 9th March 2010, 09:44
  2. Problem with Size Policy of derived QWidget
    By eehmke in forum Qt Programming
    Replies: 6
    Last Post: 12th November 2008, 14:43
  3. Delete a QGridLayout and New QGridLayout at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2007, 14:01
  4. Adjusting Widget size in a QGridLayout
    By Max Yaffe in forum Qt Programming
    Replies: 1
    Last Post: 30th July 2007, 23:03
  5. Margin size of QGridLayout
    By Cainofnod in forum Qt Programming
    Replies: 1
    Last Post: 13th January 2007, 09:59

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.