以前我也在找,后来自己写了个程序。
不过嵌入式系统一般没有鼠标操作,所以每次直接截全屏。
给你个参考,希望能帮助你:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
if (argc <= 1) {
qDebug("error, please input the image path you want to save");
return -1;
}
//其实这里可以指定任意的widget,然后只截取这个widget,还可以指定高度,宽度。
QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
if (pixmap.save(argv[1], "PNG", -1)) {
qDebug("success to save the image");
return 0;
} else {
qDebug("fail to save the image");
return -2;
}
}