开发者

Scrolling a Scroll Area in Qt

开发者 https://www.devze.com 2023-03-25 00:11 出处:网络
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 ...

I just have a Scroll Area widget that consists of several Qlabels .

take a look at the situation:

Scrolling a Scroll Area in Qt

I tried to to do the following but it didn't work out, its doesn't scroll ...

#include "form1.h"
#include &qu开发者_开发知识库ot;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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消