Scrolling a Scroll Area in Qt
14,849
Did you apply a layout to the QScrollArea?
In the designer, select the QScrollArea and then click on one of the layout buttons (or press CTRL-L). This may not give you exactly what you want, but if things can then scroll, you know that the layout is the problem.
Author by
karim
Updated on June 04, 2022Comments
-
karim almost 2 years
I just have a Scroll Area widget that consists of several Qlabels .
take a look at the situation:
I tried to to do the following but it didn't work out, its doesn't scroll ...
#include "form1.h" #include "form.h" #include "ui_form.h" #include "ui_form1.h" #include<QScrollArea> #include<QScrollBar> Form::Form(QWidget *parent) : QWidget(parent), ui(new Ui::Form) { ui->setupUi(this); ui->scrollAreaWidgetContents->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); ui->scrollAreaWidgetContents->resize(ui->scrollArea->size().width() ,ui->scrollArea->size().height()); ui->scrollArea->setWidgetResizable(true); ui->scrollArea->setWidget(ui->scrollAreaWidgetContents); ui->scrollAreaWidgetContents->adjustSize(); }
Please Can you tell me what am doing wrong or what am not understanding ?? please be specific , I would appreciate it...
-
karim over 12 yearsman ur totally right man , thanks alot , but i have this new issue , the layout will damage the structure that i have created in the form... , the pics and the buttons are bigger ... how can i solve that
-
Dirk over 12 yearslayouts can be tricky, try playing around a bit in the designer. Look at setting the size hints for the labels (min and max size).