Results 1 to 9 of 9

Thread: QListWidget question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Join Date
    Jan 2008
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8

    Default Re: QListWidget question

    Quote Originally Posted by jpn View Post
    Just add the labels in a QVBoxLayout, install the layout on a plain QWidget and set it inside a QScrollArea.
    Ok, I will try this next. Thanks for the tip.

    Edit: Got it working, only problem with it is that I cannot dynamically add or remove widgets from the box layout. Have to re-create the entire widget and all child widgets each time. I will have to try to find a better way. Here is the code I used for future knowledge.

    Qt Code:
    1. // ui.frame is a QScrollArea *
    2.  
    3. QPushButton * qpb1 = new QPushButton("Jack");
    4. QPushButton * qpb2 = new QPushButton("Jack");
    5. QPushButton * qpb3 = new QPushButton("Jack");
    6. QPushButton * qpb4 = new QPushButton("Jack");
    7. QPushButton * qpb5 = new QPushButton("Jack");
    8.  
    9.  
    10. QWidget * qw = new QWidget();
    11. QVBoxLayout * layout = new QVBoxLayout();
    12. layout->addWidget(qpb1);
    13. qw->setLayout(layout);
    14. ui.frame->setWidget(qw);
    15.  
    16. delete qw;
    17.  
    18. QWidget * qwx = new QWidget();
    19. QVBoxLayout * layoutx = new QVBoxLayout();
    20. layoutx->addWidget(qpb5);
    21. layoutx->addWidget(qpb2);
    22. layoutx->addWidget(qpb3);
    23. layoutx->addWidget(qpb4);
    24.  
    25. qwx->setLayout(layoutx);
    26. ui.frame->setWidget(qwx);
    To copy to clipboard, switch view to plain text mode 
    Last edited by rishid; 18th January 2008 at 16:37.

Similar Threads

  1. Access to QSqlTableModel::isDirty Question.
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 12th April 2007, 17:49
  2. Replies: 1
    Last Post: 15th March 2007, 20:45
  3. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34
  4. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38

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.