Results 1 to 2 of 2

Thread: Disappearing widgets in QVBoxLayout

  1. #1
    Join Date
    Jul 2007
    Location
    Trondheim
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Disappearing widgets in QVBoxLayout

    Hi.

    I have subclassed QDockWidget and added some widgets to a vertical layoutmanager in it's constructor.
    However, the widget of MyWidgetType is not visible.
    If I don't add the QListWidget, I see the MyWidgetType widget just fine.

    Could anybody give me any pointers as to what is going on here?

    Torleif

    Qt Code:
    1. this->setAllowedAreas(Qt::LeftDockWidgetArea);
    2. mContextWidget = new QWidget(this);
    3. mContextWidget->setMaximumSize(150, 250);
    4. this->setWidget(mContextWidget);
    5.  
    6. mVerticalLayout = new QVBoxLayout();
    7. mVerticalLayout->setMargin(9);
    8. mContextWidget->setLayout(mVerticalLayout);
    9.  
    10. QLabel *myLabel = new QLabel(mContextWidget);
    11. myLabel->setText("mylabel:");
    12. mVerticalLayout->addWidget(myLabel);
    13.  
    14. mListWidget = new QListWidget(mContextWidget);
    15. mVerticalLayout->addWidget(mListWidget);
    16.  
    17. MyOwnWidgetType *myWidget = new MyOwnWidgetType(mContextWidget);
    18. mVerticalLayout->addWidget(myWidget);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jul 2007
    Location
    Trondheim
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Disappearing widgets in QVBoxLayout

    setSizePolicy() solved my problem.

    Qt Code:
    1. myWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    To copy to clipboard, switch view to plain text mode 

    Torleif

Similar Threads

  1. Qt3 - Multiple transparent widgets
    By bythesea in forum Qt Programming
    Replies: 4
    Last Post: 11th September 2009, 12:24
  2. widgets behind hidden widgets not working
    By bpetty in forum Newbie
    Replies: 13
    Last Post: 7th September 2007, 21:23
  3. Performance in hiding/showing widgets
    By Paalrammer in forum Newbie
    Replies: 12
    Last Post: 14th February 2007, 19:57
  4. Replies: 11
    Last Post: 7th July 2006, 14:09
  5. Creating Widgets
    By hylke in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2006, 09:37

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.