当前位置:网站首页>Qt QScrollArea
Qt QScrollArea
2022-07-02 22:54:00 【Mr.codeee】
1. brief introduction
QScrollArea Class provides a scrolling view . The scrolling area is used to display the contents of the sub components in the frame . If the widget exceeds the size of the frame , The view can provide scroll bars , So that you can see the entire area of the child widget . Subassemblies must use setWidget() Appoint .
Easy to use :
QLabel *imageLabel = new QLabel;
QImage image("C:\\Users\\Desktop\\image\\1.webp");
imageLabel->setPixmap(QPixmap::fromImage(image));
QScrollArea *scrollArea = new QScrollArea;
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(imageLabel);
ui->verticalLayout->addWidget(scrollArea);

2. Common methods
| QWidget *widget() const | Get the part of the scrolling area |
| QWidget *takeWidget() | Remove the widget from the scrolling area , And pass the ownership of the widget to the caller . |
| void ensureVisible(int x, int y, int xmargin = 50, int ymargin = 50) | Make sure that the contents of a certain area in the viewport are visible |
| void setAlignment(Qt::Alignment) | Set alignment |
3. Example

Source code :
QScrollArea *scrollArea = new QScrollArea;
scrollArea->setBackgroundRole(QPalette::Dark); // Set background color
QWidget *widget = new QWidget;
QVBoxLayout *layout = new QVBoxLayout; // Set vertical layout
widget->setLayout(layout);
QTextEdit *t1 = new QTextEdit(widget);
QTextEdit *t2 = new QTextEdit(widget);
QTextEdit *t3 = new QTextEdit(widget);
t1->setPlaceholderText("t1");
t2->setPlaceholderText("t2");
t3->setPlaceholderText("t3");
t1->setFixedHeight(300); // Set fixed height
t2->setFixedHeight(300);
t3->setFixedHeight(300);
layout->addWidget(t1);
layout->addWidget(t2);
layout->addWidget(t3);
scrollArea->setWidget(widget);
ui->verticalLayout->addWidget(scrollArea);
边栏推荐
- Oracle PL / SQL programming
- Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
- Task and privilege level protection
- 佩服,竟然有人把高等数学这么晦涩难懂的科目,讲解得如此通俗易懂
- 【板栗糖GIS】arcmap—为什么使用自定义捕捉的时候,经典捕捉的勾要去掉呢?
- 从2022年Q1财报看携程的韧性和远景
- go 4種單例模式
- Using rendertext() to output multiple lines of text with rendertext() in R shiny
- Leetcode circular linked list (fast and slow pointer) code line by line interpretation
- php实现根据输入的年龄查询出生日期符合的数据
猜你喜欢

NC50965 Largest Rectangle in a Histogram

Oracle-游标

大话云原生之负载均衡篇-小饭馆客流量变大了

UE4 game architecture learning notes

Based on asp Net (used mobile phone sales management system) +asp Net+c # language +vs2010+ database can be used for course design and post design learning
![[foreign journal] sleep and weight loss](/img/81/42dcfae19e72a0bc761cb7a40fe5d5.jpg)
[foreign journal] sleep and weight loss

Dahua cloud native load balancing article - the passenger flow of small restaurants has increased

任务和特权级保护

牛客网:最大子矩阵

LeetCode 968. 监控二叉树
随机推荐
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
go 4種單例模式
Addition, deletion, modification and query of handwritten ORM (object relationship mapping)
百度智能云-创建人脸识别应用
用sentinel熔断比例阈值改不了,设置慢调用比例没效果
php优化foreach中的sql查询
Array advanced improvement
[error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
Leetcode circular linked list (fast and slow pointer) code line by line interpretation
高并发介绍及应对
[LeetCode] 反转字符串中的单词 III【557】
附加:【登录信息存储】与【登录状态校验】;(包括:总结了到目前为止,有关【登录信息存储】与【登录状态校验】的所有内容;)
佩服,竟然有人把高等数学这么晦涩难懂的科目,讲解得如此通俗易懂
牛客网:龙与地下城游戏
杰理之内置关机电流 1.2uA,之后不能长按开机【篇】
杰理之如何测试按键的误触率【篇】
Struct, bit segment, enumeration, union
Golang的学习路线
Jerry's charge unplugged, unable to touch the boot [chapter]