ScrollArea doesn't work.
-
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]
-
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. -
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] -
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);
}
@ -
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]