Results 1 to 14 of 14

Thread: Adding a scrollbar to a QWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Posts
    45
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Adding a scrollbar to a QWidget

    I am using Qt4.4.3. Following is my issue;

    1. I have a QWidget which I use to create a tag cloud view (a weighted list placed in a rectangle area where the words (text) are of varying size). See attachment.
    2. The QWidget which has the tag cloud is created at runtime
    3. The problem is when the amount of text is large, and its area exceeds that of the container QWidget, a ScrollBar DOESN't appear. You can see this in the attachment

    4. I tried enclosing the the QWidget into a QScrollArea as follows, but it doesn't work, the scrollbar doesn't appear.
    Qt Code:
    1. QWidget* tagCloudDisplay; // This is the widget which holds the tag cloud
    2.  
    3. QScrollArea *tagCloudScrollArea = new QScrollArea;
    4. tagCloudScrollArea->setGeometry(tagCloudDisplay->geometry());
    5. tagCloudScrollArea->setWidget(mainWidget->tagCloudDisplay); // MainWidget is the container widget i.e. the window itself
    6. tagCloudScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    7. tagCloudScrollArea->setWidgetResizable(true);
    To copy to clipboard, switch view to plain text mode 
    5. Is it possible to havea ScrollArea for a QWidget, or should I be using a different type of widget instead of QWidget Eg a QTextEdit to create the tag cloud?

    Any advise or suggestions will really be appreciated.
    Thanks.
    Attached Images Attached Images

Similar Threads

  1. QGraphicsView and adding QWidget with transparent areas
    By sting73 in forum Qt Programming
    Replies: 2
    Last Post: 28th April 2009, 12:19
  2. Replies: 11
    Last Post: 25th February 2009, 18:35
  3. Replies: 0
    Last Post: 11th November 2008, 16:36
  4. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2008, 00:45
  5. GraphicsView/GraphicsScene: scrollbar policy Qt::ScrollBarAsNeeded
    By Pieter from Belgium in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2007, 14:15

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.