当前位置:网站首页>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();
边栏推荐
- Research Report on the development trend and competitive strategy of the global pipeline robot inspection camera industry
- 既不是研发顶尖高手,也不是销售大牛,为何偏偏获得 2 万 RMB 的首个涛思文化奖?
- MySQL日志
- [commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial
- SWT / anr problem - how to capture performance trace
- [dynamic programming] p1004 grid access (four-dimensional DP template question)
- C language course design topic
- Provincial election + noi Part 10 probability statistics and polynomials
- Basic operation of queue (implemented in C language)
- Force deduction solution summary 241- design priority for operation expression
猜你喜欢
【牛客网刷题系列 之 Verilog快速入门】~ 使用函数实现数据大小端转换
【商业终端仿真解决方案】上海道宁为您带来Georgia介绍、试用、教程
Websocket (simple experience version)
Use lambda function URL + cloudfront to realize S3 image back to source
[IOT design. Part I] stm32+ smart cloud aiot+ laboratory security monitoring system
TDengine 连接器上线 Google Data Studio 应用商店
This paper introduces an implementation scheme to enhance the favorite transaction code management tool in SAP GUI
How to view the state-owned enterprises have unloaded Microsoft office and switched to Kingsoft WPS?
[flask] flask starts and implements a minimal application based on flask
[IOT completion. Part 2] stm32+ smart cloud aiot+ laboratory security monitoring system
随机推荐
光环效应——谁说头上有光的就算英雄
被裁三個月,面試到處碰壁,心態已經開始崩了
Realize queue with stack and stack with queue (C language \leetcode\u 232+225)
Is the futures company found on Baidu safe? How do futures companies determine the regularity
Using CMD to repair and recover virus infected files
Research Report on development trend and competitive strategy of global 4-aminodiphenylamine industry
In depth cooperation | Taosi data cooperates with changhongjia Huawei customers in China to provide tdengine with powerful enterprise level products and perfect service guarantee
奔涌而来的数字化浪潮,将怎样颠覆未来?
C 语言基础
El form item regular verification
Provincial election + noi Part 10 probability statistics and polynomials
Minimum spanning tree and bipartite graph in graph theory (acwing template)
户外LED显示屏应该考虑哪些问题?
Salesforce、约翰霍普金斯、哥大 | ProGen2: 探索蛋白语言模型的边界
[repair version] imitating the template of I love watching movies website / template of ocean CMS film and television system
Research Report on the development trend and competitive strategy of the global aviation leasing service industry
Research Report on development trend and competitive strategy of global consumer glassware industry
Go integrates logrus to realize log printing
Opencv interpolation mode
8 best practices to protect your IAC security!