Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7563395
  • 博文数量: 961
  • 博客积分: 15795
  • 博客等级: 上将
  • 技术积分: 16612
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-07 14:23
文章分类

全部博文(961)

文章存档

2016年(1)

2015年(61)

2014年(41)

2013年(51)

2012年(235)

2011年(391)

2010年(181)

分类: 嵌入式

2013-12-10 17:21:11


点击(此处)折叠或打开

  1. #include <QApplication>
  2. #include <QString>
  3. #include <QPixmap>
  4. #include <QDesktopWidget>

  5. #define DEFAULT_NAME "/mnt/screenshot.PNG"

  6. int main(int argc, char *argv[])
  7. {
  8.     QApplication app(argc, argv);

  9.     QString fileName = DEFAULT_NAME;
  10.     if (argc > 1)
  11.         fileName = argv[1];

  12.     QPixmap scrPic = QPixmap::grabWindow(QApplication::desktop()->winId());
  13.     bool ret = scrPic.save(fileName, "PNG");
  14.     
  15.     if (ret)
  16.     {
  17.         qDebug("Screenshot is saved to: %s", fileName.toLatin1().data());
  18.     }
  19.     else
  20.     {
  21.         qCritical("Failed to save file: %s", fileName.toLatin1().data());
  22.     }
  23.     
  24.     return 0;
  25. }
源码文件:copyscreen.rar
阅读(1791) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~