Results 1 to 4 of 4

Thread: QScrollArea with a VBoxLayout

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

    Default QScrollArea with a VBoxLayout

    I am trying to put a VboxLayout inside a QScrollArea. I have this to work with the code below with QPushButton, but if I try a custom widget I maed with QtDesigner the widget is not displayed.

    One thing I tried was just to create a VBoxlayout (without a scroll area) and add my custom widget to it, and this worked fine. So it must have something to do with the scroll area setup, but I cannot tell.

    Here is my code. (qpb1 shows up fine, but ne1 does not show up) (ui.frame is a QScrollArea)

    Qt Code:
    1. QPushButton * qpb1 = new QPushButton("Jack");
    2. NameEntry * ne1 = new NameEntry("John", "NU", QPixmap(":/fb/images/1604859.jpg"), "123456789", p );
    3.  
    4. QWidget * qw = new QWidget();
    5. QVBoxLayout * layout = new QVBoxLayout();
    6. layout->addWidget(ne1);
    7. layout->addWidget(qpb1);
    8. qw->setLayout(layout);
    9. ui.frame->setWidget(qw);
    To copy to clipboard, switch view to plain text mode 
    Thanks for the help.

    Here is a snip from NameEntry if that is needed:
    Qt Code:
    1. class NameEntry : public QWidget {
    2. Q_OBJECT
    3.  
    4. public:
    5. NameEntry(QString name, QString info, QPixmap image, QString id, Profile & p, QWidget *parent = 0) :
    6. QWidget(parent), p(p), idNum(id) {
    7. ui.setupUi(this);
    8.  
    9. setName(name);
    10. setInfo(info);
    11. setImage(image);
    12. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QScrollArea with a VBoxLayout

    Does NameEntry reimplement QWidget::sizeHint()? For more details, see Custom Widgets in Layouts.
    J-P Nurmi

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

    rishid (19th January 2008)

  4. #3
    Join Date
    Jan 2008
    Posts
    27
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QScrollArea with a VBoxLayout

    Yep that was it.

    Man you know everything, you should write a book on this stuff.

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QScrollArea with a VBoxLayout

    Quote Originally Posted by rishid View Post
    Man you know everything, you should write a book on this stuff.
    Heh thanks. One can boost his/her Qt knowledge a lot by following this forum. I'm not really a book writer type of person but feel free to suggest wiki article ideas.
    J-P Nurmi

Similar Threads

  1. QScrollArea
    By sabeesh in forum Qt Programming
    Replies: 7
    Last Post: 2nd November 2007, 10:33
  2. QScrollArea and resizing
    By rarefluid in forum Qt Programming
    Replies: 8
    Last Post: 22nd July 2007, 14:18
  3. QScrollArea With Custom Widgets
    By VireX in forum Qt Programming
    Replies: 30
    Last Post: 22nd April 2007, 16:48
  4. Replies: 2
    Last Post: 8th October 2006, 20:14
  5. QScrollArea problem positioning a QWidget inside
    By Spectator in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 22: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.