QT 4截图

// 界面截图
void GMainWindow::widgetScreenshot()
{
    QString filePathName = "Screen-.png"; 
    
    QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()->winId()); 
    
    //filePathName += QDateTime::currentDateTime().toString("yyyy-MM-dd hh-mm-ss"); 
    
    //filePathName += ".png"; 
    
    if(!pixmap.save(filePathName))
    { 
        printf("[%s,%d]\n", __FUNCTION__, __LINE__);
    }

}
 

猜你喜欢

转载自blog.csdn.net/huabiaochen/article/details/123471584
qt4