当前位置:网站首页>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 aviation leasing service industry
- sqlilabs less9
- How will the surging tide of digitalization overturn the future?
- Using CMD to repair and recover virus infected files
- 241. Design priorities for operational expressions
- Go integrates logrus to realize log printing
- El form item regular verification
- 日志中打印统计信息的方案
- How to pass array parameters in get request
- 2022 PMP project management examination agile knowledge points (6)
猜你喜欢

sqlilabs less10

That hard-working student failed the college entrance examination... Don't panic! You have another chance to counter attack!

How to view the state-owned enterprises have unloaded Microsoft office and switched to Kingsoft WPS?

SQLAchemy 常用操作

How will the surging tide of digitalization overturn the future?

Use the right scene, get twice the result with half the effort! Full introduction to the window query function and usage scenarios of tdengine

C 语言基础

问题随记 —— Oracle 11g 卸载

643. Maximum average number of subarrays I

Logic is a good thing
随机推荐
Basic operation of queue (implemented in C language)
Vnctf2022 open web gocalc0
User defined annotation realizes the function of verifying information
643. Maximum average number of subarrays I
[NLP] pre training model - gpt1
Phpcms realizes the direct Alipay payment function of orders
Research Report on the development trend and competitive strategy of the global chemical glassware industry
[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 diamond suspension industry
Journal MySQL
Leetcode (69) -- square root of X
队列的基本操作(C语言实现)
Research Report on the development trend and competitive strategy of the global camera filter bracket industry
[IOT completion. Part 2] stm32+ smart cloud aiot+ laboratory security monitoring system
sqlilabs less-11~12
2022-2-15 learning the imitation Niuke project - Section 3 post details
【修复版】仿我爱看电影网站模板/海洋CMS影视系统模板
2022-2-15 learning xiangniuke project - Section 4 business management
MIT团队使用图神经网络,加速无定形聚合物电解质筛选,促进下一代锂电池技术开发
111. Minimum depth of binary tree