当前位置:网站首页>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();
边栏推荐
- Summary of leetcode's dynamic programming 5
- [flask] flask starts and implements a minimal application based on flask
- Realize queue with stack and stack with queue (C language \leetcode\u 232+225)
- Provincial election + noi Part XI others
- Research Report on the development trend and competitive strategy of the global ultrasonic scalpel system industry
- TDengine 连接器上线 Google Data Studio 应用商店
- 那个很努力的学生,高考失败了……别慌!你还有一次逆袭机会!
- C 语言进阶
- 241. 为运算表达式设计优先级
- Websocket (simple experience version)
猜你喜欢

2022-2-15 learning the imitation Niuke project - post in Section 2

【商业终端仿真解决方案】上海道宁为您带来Georgia介绍、试用、教程

MIT团队使用图神经网络,加速无定形聚合物电解质筛选,促进下一代锂电池技术开发

Vnctf2022 open web gocalc0

In depth cooperation | Taosi data cooperates with changhongjia Huawei customers in China to provide tdengine with powerful enterprise level products and perfect service guarantee

如何看待国企纷纷卸载微软Office改用金山WPS?

原来程序员搞私活这么赚钱?真的太香了
![[Verilog quick start of Niuke question series] ~ use functions to realize data size conversion](/img/e1/d35e1d382e0e945849010941b219d3.png)
[Verilog quick start of Niuke question series] ~ use functions to realize data size conversion

Play with grpc - communication between different programming languages

Tdengine connector goes online Google Data Studio app store
随机推荐
About the use of HTTP cache validation last modified and Etag
Research Report on the development trend and competitive strategy of the global powder filling machine industry
[dynamic programming] interval dp:p1005 matrix retrieval
One of the data Lake series | you must love to read the history of minimalist data platforms, from data warehouse, data lake to Lake warehouse
深度合作 | 涛思数据携手长虹佳华为中国区客户提供 TDengine 强大企业级产品与完善服务保障
Research Report on the development trend and competitive strategy of the global traditional computer industry
【IoT毕设.上】STM32+机智云AIoT+实验室安全监控系统
What "hard core innovations" does Intel have in the first half of 2022? Just look at this picture!
生成随机数(4位、6位)
Use of Oracle database objects
Is the futures company found on Baidu safe? How do futures companies determine the regularity
[dynamic programming] p1004 grid access (four-dimensional DP template question)
How will the surging tide of digitalization overturn the future?
【牛客网刷题系列 之 Verilog快速入门】~ 多功能数据处理器、求两个数的差值、使用generate…for语句简化代码、使用子模块实现三输入数的大小比较
【阶段人生总结】放弃考研,参与到工作中,已经顺利毕业了,昨天刚领毕业证
Research Report on development trend and competitive strategy of global vibration polishing machine industry
Open source internship experience sharing: openeuler software package reinforcement test
Force deduction solution summary 241- design priority for operation expression
Leetcode(69)——x 的平方根
Summary of leetcode's dynamic programming 5