当前位置:网站首页>qt捕获界面为图片或label显示
qt捕获界面为图片或label显示
2022-07-01 14:30:00 【码肥人壮】
在软件的开发中,有些特殊的功能实现,需要去截取ui的界面图片,比如我们在实现某些动画中,直接控制ui界面或控件是无法实现的,就算能够实现也是大打折扣,像翻页效果、旋转效果等等。
以上问题,在qwidget可以使用grab()函数截取界面或控件为QPixmap对象,然后保存为图片也好,label显示实现你想要的动画也好。
代码如下:
QLabel *mLabel = new QLabel(parent);
mLabel->resize(QSize(yourWidget->width(),yourWidget->height()));
mLabel->setPixmap(yourWidget->grab()); //捕获当前界面并绘制到label上
mLabel->setAttribute(Qt::WA_DeleteOnClose); //设置属性(关闭时删除)
mLabel->show();
mLabel->raise();
边栏推荐
- Blog recommendation | in depth study of message segmentation in pulsar
- 使用net core 6 c# 的 NPOI 包,读取excel..xlsx单元格内的图片,并存储到指定服务器
- Research Report on the development trend and competitive strategy of the global commercial glassware industry
- How to view the state-owned enterprises have unloaded Microsoft office and switched to Kingsoft WPS?
- How can we protect our passwords?
- 生成随机数(4位、6位)
- Fundamentals of C language
- Research Report on the development trend and competitive strategy of the global axis measurement system industry
- sqlilabs less9
- SWT / anr problem - how to capture performance trace
猜你喜欢

Today, with the popularity of micro services, how does service mesh exist?

队列的基本操作(C语言实现)

C#学习笔记(5)类和继承

Tdengine connector goes online Google Data Studio app store

What "hard core innovations" does Intel have in the first half of 2022? Just look at this picture!

TDengine 连接器上线 Google Data Studio 应用商店

博文推荐 | 深入研究 Pulsar 中的消息分块

Minimum spanning tree and bipartite graph in graph theory (acwing template)

sqlilabs less-8

Websocket (simple experience version)
随机推荐
When the main process architecture game, to prevent calls everywhere to reduce coupling, how to open the interface to others to call?
队列的基本操作(C语言实现)
SWT/ANR问题--如何捕获性能的trace
C 语言基础
券商万1免5证券开户是合理安全的吗,怎么讲
What problems should be considered for outdoor LED display?
sqlilabs less10
In depth cooperation | Taosi data cooperates with changhongjia Huawei customers in China to provide tdengine with powerful enterprise level products and perfect service guarantee
App automation testing Kaiyuan platform appium runner
Research Report on the development trend and competitive strategy of the global high temperature label industry
光环效应——谁说头上有光的就算英雄
30 Devops interview questions and answers
[dynamic programming] interval dp:p1005 matrix retrieval
Basis of target detection (NMS)
C 语言进阶
Texstudio tutorial
Open source internship experience sharing: openeuler software package reinforcement test
Build your own website (21)
Sorting learning sorting
数据湖系列之一 | 你一定爱读的极简数据平台史,从数据仓库、数据湖到湖仓一体