当前位置:网站首页>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);
边栏推荐
- Source code analysis - lightweight asynchronous crawler framework Ruia
- 送给即将工作的自己
- PHP implements querying the data matching the date of birth according to the entered age
- U++ learning notes - relaxation
- Golang's learning route
- Oracle-游标
- Leetcode circular linked list (fast and slow pointer) code line by line interpretation
- [leetcode] there are duplicate elements [217]
- Higher order operation of bits
- 钟薛高回应产品1小时不化:含固体成分 融化不能变成水
猜你喜欢
Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
百度智能云-创建人脸识别应用
P7072 [CSP-J2020] 直播获奖
Array advanced improvement
加油站[问题分析->问题转换->贪心]
【板栗糖GIS】global mapper 如何通过dsm批量制作贴地等高线
[leetcode] reverse the word III in the string [557]
Qt QScrollArea
kubernetes 使用主机名将 pod 分配在指定节点上
Jatpack------LiveData
随机推荐
The kth largest element in the [leetcode] array [215]
Jielizhi, production line assembly link [chapter]
图形视图框架
傑理之修改不需要長按開機功能【篇】
P1007 独木桥
go 4种单例模式
[error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
手写ORM(对象关系映射)增删改查
go 4種單例模式
go 条件变量
[chestnut sugar GIS] ArcMap - why should the tick of classic capture be removed when using custom capture?
[leetcode] reverse string [344]
U++ learning notes - relaxation
Golang的学习路线
地方经销商玩转社区团购模式,百万运营分享
Go four singleton modes
[leetcode] reverse the word III in the string [557]
加油站[问题分析->问题转换->贪心]
Kubernetes uses the host name to allocate the pod on the specified node
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection