1、#include <QScreen>2、
QScreen* screen = QGuiApplication::primaryScreen();//QScreen没有构造函数 QPixmap p = screen->grabWindow(ui->textEdit->winId()); QImage image = p.toImage();