Results 1 to 3 of 3

Thread: QWidget + QScrollArea = confused

  1. #1
    Join Date
    Jan 2011
    Posts
    55
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QWidget + QScrollArea = confused

    Hi, I have developed an application with a main QWidget, which contains other controls. I have declared it like this:

    myWindow = new QWidget(0, "mainWindow");
    myWindow->show();
    myWindow->setWindowTitle("Window Title");

    The widget is resizable, and how'd like to have scrollbars appear when it's size is reduced. I tried to use QScrollArea without success (also Googled but couldn't find a simple example).

    Could somebody please give me a hint? Thanks

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWidget + QScrollArea = confused

    For example:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent)
    3. {
    4. QScrollArea* scroll = new QScrollArea();
    5. QWidget* w = new QWidget();
    6. w->setWindowTitle("test");
    7. w->setMinimumSize(300,200);
    8. scroll->setWidget(w);
    9. this->setCentralWidget(scroll);
    10. }
    To copy to clipboard, switch view to plain text mode 
    When MainWindow is resized below 300x200 scroll bars will appear.

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

    papillon (16th November 2011)

  4. #3
    Join Date
    Jan 2011
    Posts
    55
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QWidget + QScrollArea = confused

    Thank you very much. Appreciated.

Similar Threads

  1. QVBOxLayout problem with QSCrollArea and QWidget
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 16th March 2011, 10:43
  2. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2008, 00:45
  3. Confused QWidget and QDialog behavior
    By munna in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2006, 13:14
  4. size issues for custom QWidget in QScrollArea
    By anotheruser in forum Qt Programming
    Replies: 1
    Last Post: 27th April 2006, 15:52
  5. QScrollArea problem positioning a QWidget inside
    By Spectator in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 23: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.