Results 1 to 2 of 2

Thread: Button visibility and layout participation

  1. #1
    Join Date
    Apr 2009
    Posts
    63
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Button visibility and layout participation

    I have a bunch of buttons in a horizontal row (i.e. in a QHBoxLayout). I want to be able to set one of those buttons "invisible" but still participate in the layout. When I do setVisible(false) it does set it invisible, but it respaces all the buttons in the QHBoxLayout. I want it to behave as if the button is still there, just not visible. I suppose in other words I simply want it to be transparent. Wondering what the best mechanism for achieving this is. Thanks!

  2. #2
    Join Date
    Mar 2009
    Posts
    25
    Thanked 2 Times in 2 Posts

    Default Re: Button visibility and layout participation

    Pseudo code,

    QBoxLayout *layout;
    QWidget *myWidget2Hide;
    index = indexInLayout(myWidget2Hide, layout);
    myWidget2Hide->hide();
    layout->insertStretch(index, stretch);

    Here the important things are,
    a) index
    b) stretch, usually set to 1, but if the other widgets have different stretches, you might want to tweak this value

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.