QT在windows下实现截屏操作并保存为png图片 - 小众知识

QT在windows下实现截屏操作并保存为png图片

2014-10-08 15:09:11 苏内容
  标签: QT/截屏/保存
阅读:5699
QPixmap originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());

 QString format = "png";
     QString initialPath = QDir::currentPath() + tr("/untitled.") + format;

     QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
                                initialPath,
                                tr("%1 Files (*.%2);;All Files (*)")
                                .arg(format.toUpper())
                                .arg(format));
     if (!fileName.isEmpty())
         originalPixmap.save(fileName, format.toAscii());
扩展阅读
相关阅读
© CopyRight 2010-2021, PREDREAM.ORG, Inc.All Rights Reserved. 京ICP备13045924号-1