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. QScrollArea issue
Forum Updated to NodeBB v4.3 + New Features

QScrollArea issue

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.3k 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    I have a container widget that contains only a vertical layout, to which empty push buttons are added. The widget works just fine if I add it to a parent widget (1)

    But when I set the container widget to the scroll area inside the parent widget, nothing really shows when I add buttons (2)

    If I add a single button to the container widget in its constructor, then more buttons do show but the layout is all wrong and the scroll area is not really working at all (3)

    !http://i41.tinypic.com/19pbw5.png(problem)!

    @ mainLayout = new QVBoxLayout(this);
    addOne = new QPushButton("Add one", this);
    scrollArea = new QScrollArea(this);

    container = new Container(this);
    scrollArea->setWidget(container);
    
    
    mainLayout->addWidget(addOne);
    mainLayout->addWidget(scrollArea);
    

    // mainLayout->addWidget(container);

    setLayout(mainLayout);
    connect(addOne, SIGNAL(clicked()), this, SLOT(addOneSlot()));@
    

    Any ideas?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You need to add stuff not to the QScrollArea itself, but to the widget returned by widget()

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #3

        ^^I didn't really get what you mean by that.

        I do not add anything to the scroll area itself, the content of scrollArea is set by setWidget(), and extra stuff I add to the layout that is inside the container widget.

        @void Widget::addOneSlot()
        {
        container->layout->addWidget(new QPushButton(container));
        // dumpObjectTree();
        }@

        But even without adding anything, just setting the container widget to the scroll area doesn't work correctly, the widget itself is being rendered just ok when put in a layout, but when I put it inside the scroll area it doesn't fill it, instead occupies just the upper left corner as in the screenshot above.

        Adding stuff to the container widget works just fine, putting the container inside the scroll area is problematic.

        What is also odd is without that one initial push button inside container, the addOneSlot doesn't seem to add anything, or actually IT DOES ADD a push button, as dumpObjectTree() indicates, it is more like the container widget itself is not added to the scroll area at all if it is just one empty layout with nothing in.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          elmigranto
          wrote on last edited by
          #4

          [quote author="Deleted Member # 269f" date="1333018338"]^^I didn't really get what you mean by that.[/quote]Probably something like this (worked for me):
          @ui->scrollArea->widget()->setLayout(scrollLayout);@

          1 Reply Last reply
          0

          • Login

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