码迷,mamicode.com
首页 > 其他好文 > 详细

QT4和QT5中的截图

时间:2020-05-02 19:01:40      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:size   使用   desktop   details   tps   idg   this   default   qwidget   

//this->m_pixMap = QPixmap::grabWindow(QApplication::desktop()->winId(), 0, 0, -1, -1);
//this->m_pixMap = QWidget::grab(QRect( QPoint( 0, 0 ), QSize( -1, -1 ) ));
QScreen* screen = QGuiApplication::primaryScreen();
this->m_pixMap = screen->grabWindow(QApplication::desktop()->winId(), 0, 0, -1, -1);

使用QWidget::grab再QT5中会有警告
this function is deprecated, use QScreen::grabWindow() instead. Defaulting to primary screen.

使用第二种只截取当前App的界面,非桌面全屏
使用第三种没有警告,且截取的是桌面全屏

参考 Qt5和Qt4的简单截屏;

QT4和QT5中的截图

标签:size   使用   desktop   details   tps   idg   this   default   qwidget   

原文地址:https://www.cnblogs.com/kuikuitage/p/12818741.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!