1 Attachment(s)
Grabbing QTableWidget's viewport
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:
Code:
int w = table->model()->columnCount() * table->columnWidth(0);
int h = table->model()->rowCount() * table->rowHeight(0);
QPainter::setRedirected(table
->viewport
(),
&pixmap
);
QPainter::restoreRedirected(table
->viewport
());
pixmap.save("viewport.png", "png");
Any ideas? Thanks in advance.
Re: Grabbing QTableWidget's viewport
The viewport is smaller than the view. The scrolled canvas is purely virtual. Thus you can't just render the viewport and have all the table on the pixmap because the viewport can only hold that many items that are currently displayed in the widget.
Re: Grabbing QTableWidget's viewport
I see. So what are my options? Use the delegate to paint each cell? I would probably need to draw the grid manually, right?
Re: Grabbing QTableWidget's viewport
You have to do everything manually, I'm afraid.