u-ra
27th November 2009, 14:16
Hi,
I'm trying to grab the entire viewport of a QTableWidget using redirection. However, the result is still clipped to QTableWidget's rect. Here's the code:
int w = table->model()->columnCount() * table->columnWidth(0);
int h = table->model()->rowCount() * table->rowHeight(0);
QPixmap pixmap(w, h);
QPainter::setRedirected(table->viewport(), &pixmap);
QPaintEvent event(QRect(0, 0, w, h));
QApplication::sendEvent(table->viewport(), &event);
QPainter::restoreRedirected(table->viewport());
pixmap.save("viewport.png", "png");
Any ideas? Thanks in advance.
I'm trying to grab the entire viewport of a QTableWidget using redirection. However, the result is still clipped to QTableWidget's rect. Here's the code:
int w = table->model()->columnCount() * table->columnWidth(0);
int h = table->model()->rowCount() * table->rowHeight(0);
QPixmap pixmap(w, h);
QPainter::setRedirected(table->viewport(), &pixmap);
QPaintEvent event(QRect(0, 0, w, h));
QApplication::sendEvent(table->viewport(), &event);
QPainter::restoreRedirected(table->viewport());
pixmap.save("viewport.png", "png");
Any ideas? Thanks in advance.