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. ScrollArea doesn't work.
Forum Updated to NodeBB v4.3 + New Features

ScrollArea doesn't work.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.7k 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.
  • L Offline
    L Offline
    leandrogs
    wrote on last edited by
    #1

    Hello guys! I am developing an graphical application with Qt/C++ and i have to refactor my entire project to make my life easy. The problem that i have is, i believe, about the Layout type that i have defined at my mainWindow. Here follows the code:

    @#include "dengueme.h"
    #include "ui_dengueme.h"

    #include <QtGui>

    DengueME::DengueME(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::DengueME)
    {
    ui->setupUi(this);

    connect(this->ui->actionNew, SIGNAL(triggered()), this, SLOT(insertFrame()));
    

    }

    DengueME::~DengueME()
    {
    delete ui;
    }

    void DengueME::insertFrame()
    {
    Path *p = new Path();
    Path *p2 = new Path();
    Path *p3 = new Path();
    Path *p4 = new Path();
    Path *p5 = new Path();

    QVBoxLayout *Layout = new QVBoxLayout;
    
    Layout->addWidget(p);
    Layout->addWidget(p2);
    Layout->addWidget(p3);
    Layout->addWidget(p4);
    Layout->addWidget(p5);
    
    this->ui->scrollArea->setLayout(Layout);
    

    }@

    The Path class does not have any relevant code to the interface, because it is defined at Designer Form. This is what's happening:

    !https://dl.dropbox.com/u/45191488/Untitled-1.jpg(Screenshot)!

    I have called the same element repeatedly just to fill the scrollArea to test the scrollbar.

    [edit: updated for picture, koahnig]

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Please use picture button for posting images. They are directly displayed when you post your dropbox link with the "6th button":http://qt-project.org/wiki/ForumHelp#b642e0c67b7a32cc0b833ea119693dce
      That makes it easier to read your post for everybody.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leandrogs
        wrote on last edited by
        #3

        I'm sorry about that!
        [quote author="koahnig" date="1363369684"]Please use picture button for posting images. They are directly displayed when you post your dropbox link with the "6th button":http://qt-project.org/wiki/ForumHelp#b642e0c67b7a32cc0b833ea119693dce
        That makes it easier to read your post for everybody. [/quote]

        1 Reply Last reply
        0
        • Chris KawaC Online
          Chris KawaC Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You've put layout on the scroll area while you should be putting it on the scroll area contents:

          @void DengueME::insertFrame()
          {
          Path *p = new Path();
          Path *p2 = new Path();
          Path *p3 = new Path();
          Path *p4 = new Path();
          Path *p5 = new Path();

          QVBoxLayout *Layout = new QVBoxLayout;
          
          Layout->addWidget(p);
          Layout->addWidget(p2);
          Layout->addWidget(p3);
          Layout->addWidget(p4);
          Layout->addWidget(p5);
          
          QWidget* w = new QWidget();
          w->setLayout(Layout);
          ui->scrollArea->setWidget(w);
          

          }
          @

          1 Reply Last reply
          0
          • L Offline
            L Offline
            leandrogs
            wrote on last edited by
            #5

            This works fine for me! Thank you!
            [quote author="Krzysztof Kawa" date="1363370131"]You've put layout on the scroll area while you should be putting it on the scroll area contents:

            @void DengueME::insertFrame()
            {
            Path *p = new Path();
            Path *p2 = new Path();
            Path *p3 = new Path();
            Path *p4 = new Path();
            Path *p5 = new Path();

            QVBoxLayout *Layout = new QVBoxLayout;
            
            Layout->addWidget(p);
            Layout->addWidget(p2);
            Layout->addWidget(p3);
            Layout->addWidget(p4);
            Layout->addWidget(p5);
            
            QWidget* w = new QWidget();
            w->setLayout(Layout);
            ui->scrollArea->setWidget(w);
            

            }
            @[/quote]

            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