How to create screenshot of QWidget?
From QWidget::Grab:
QPixmap QWidget::grab(const QRect &rectangle = QRect(QPoint(0, 0), QSize(-1, -1)))
You can use QWidget::render
for this. Assuming rectangle
is a QRect:
QPixmap pixmap(rectangle->size());
widget->render(&pixmap, QPoint(), QRegion(rectangle));