Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Scrollable Widget as container for other widgets
Forum Updated to NodeBB v4.3 + New Features

[Solved] Scrollable Widget as container for other widgets

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 5.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ronM71
    wrote on 30 May 2012, 16:04 last edited by
    #1

    Here's what I'm trying to achieve:

    I'd like to have a widget I can place anywhere on a view/form, that'll be able to contain other child controls and view them using a scroll bar, if necessary. The size of such parent widget can be 100x100 pixels, but it can host a "logical" area of 500x500 where controls are placed and the user should be able to reach them via vertical and horizontal scroll bars (that appear when the sub-area is larger than the viewport).

    I tried using QAbstractScrollArea for this, but although I can see my controls inside of it, I can't get it to show scroll bars. This is what I'm doing inside the constructor for the QAbstractScrollArea derived class:

       @ // add controls
    

    QPushButton *a = new QPushButton(QString("a"), this);
    a->setGeometry(QRect(10,10,100,30));
    QPushButton *b = new QPushButton(QString("b"), this);
    b->setGeometry(QRect(10,40,100,30));
    QPushButton *c = new QPushButton(QString("c"), this);
    c->setGeometry(QRect(10,70,100,30));
    QPushButton *d = new QPushButton(QString("d"), this);
    d->setGeometry(QRect(10,100,100,30));
    QPushButton *e = new QPushButton(QString("e"), this);
    e->setGeometry(QRect(10,130,100,30));
    QPushButton *f = new QPushButton(QString("f"), this);
    f->setGeometry(QRect(10,160,100,30));
    QPushButton *g = new QPushButton(QString("g"), this);
    g->setGeometry(QRect(10,190,100,30));
    QPushButton *h = new QPushButton(QString("h"), this);
    h->setGeometry(QRect(10,220,100,30));

    this->addScrollBarWidget(new QScrollBar(this), Qt::AlignRight);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);@

    Any ideas will be most welcome.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 30 May 2012, 20:08 last edited by
      #2

      I would put all the buttons into a container widget with a layout (a QWidget is sufficient) and put that as the viewport widget of a [[Doc:QScrollArea]]. The "sipdialog example":/doc/qt-4.8/dialogs-sipdialog.html could be of help here.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • T Offline
        T Offline
        troubalex
        wrote on 31 May 2012, 09:05 last edited by
        #3

        Reported as no longer relevant -- I interpret it as solved.

        THE CAKE IS A LIE
        Web Community Manager - Qt Development Frameworks

        1 Reply Last reply
        0

        1/3

        30 May 2012, 16:04

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved