QT4和QT5中的截圖


//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的簡單截屏;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM