QWidget QPixmap 截取控件并保存为图片 基本控件(十二)
程序员文章站
2022-05-28 11:38:17
...
一、功能
void QWidget::render(QPaintDevice *target, const QPoint &targetOffset = QPoint(), const QRegion &sourceRegion = QRegion(), QWidget::RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren))
Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. Rendering starts at targetOffset in the target.
二、代码
QPixmap pixmap(this->size());
render(&pixmap);
pixmap.save(QCoreApplication::applicationDirPath() + "/1.jpg");
三、效果图