win7下Qt5获取桌面截图

os:window7

Qt:5.3

//begin:get system desktop and save it as a QPixmap.
    QScreen* screen = QGuiApplication::primaryScreen();
    //return the desktop window(root window).
    QDesktopWidget* desktop = QApplication::desktop();
    //get the geometry size of desktop.
    QRect rect = desktop->screenGeometry();

    //grab the contents of the given window resticted by Wid & QRect.
    mFullScreen = screen->grabWindow(desktop->winId(), 0, 0, rect.width(), rect.height());
    pLabelFullScreen->setPixmap(mFullScreen);
    pLabelFullScreen->showFullScreen();
    //end:get system desktop and save it as a QPixmap.


你可能感兴趣的:(Qt&Pyside)