Results 1 to 3 of 3

Thread: [SOLVED] widgets moving after setVisible(false) in aQLayout

  1. #1
    Join Date
    Sep 2009
    Location
    france
    Posts
    5
    Thanks
    1
    Platforms
    Windows

    Default [SOLVED] widgets moving after setVisible(false) in aQLayout

    Hello,

    I very much like Qt, witch works very well for me up to now, and allow fast coding!

    I have a very simple pb tough :
    Given some widget displayed in a layout, i would like to hide some of them without moving others, in a QVBoxlayout for example.

    I did not find the answer of this elementary pb.
    Thanks in advance.

    dmcr
    Last edited by dmcr; 3rd February 2010 at 17:06.

  2. #2
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: widgets moving after setVisible(false) in aQLayout

    Consider putting a spacer along with the item in a separate V or H layout, and then adding this layout to your main layout. This way the spacer would fill all the free space when the item is hidden.

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

    dmcr (3rd February 2010)

  4. #3
    Join Date
    Sep 2009
    Location
    france
    Posts
    5
    Thanks
    1
    Platforms
    Windows

    Default Re: widgets moving after setVisible(false) in aQLayout

    //this not so obvious thing for me was not so long!

    QWidget *abWidget::createWidgetWithSpacer( QWidget* w)
    {
    QWidget *wdgt = new QWidget;
    QHBoxLayout *l = new QHBoxLayout;

    l->addWidget( w, 0, Qt::AlignCenter ) ;
    l->addSpacing(w->width());

    wdgt->setLayout(l);
    return wdgt;
    }

Similar Threads

  1. QTextBlock::setVisible(false) has no effect [unresolved]
    By JohannesMunk in forum Qt Programming
    Replies: 7
    Last Post: 19th February 2010, 15:16
  2. Avoid moving widgets
    By desch in forum Qt Programming
    Replies: 5
    Last Post: 9th April 2009, 06:27
  3. setVisible(false) doesn't work
    By sepehr in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2009, 16:20
  4. Replies: 3
    Last Post: 29th May 2008, 13:50
  5. Moving widgets within a layout.
    By importantman in forum Qt Programming
    Replies: 6
    Last Post: 26th May 2007, 20:21

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.