Hello, guys,
Very glad to be here. This is my first post.
I recently have a problem with saving my application interface (some X-Y charts) to PNG files using QPixmap::grabWidget and QTabWidget. My chart is drawn on a QwtPlot object in the pages of a QTabWidget object. And I have 9 pages totally. I want each single page be saved automatically to a PNG file for later review (no button press, mouse click etc.). The files are saved, but some components of the chart are missing (looks like the chart is not done yet, so I put Sleep(500) in there). I tried grabWindow(), but since the pages of the QTabWidget are not visible at this moment of time, so I can not get what I want. I am using QT 3.3.6 and Qwt 4.2 and MSVS 2005.
I attach some of my codes, hope someone can help me out. Thanks in advance.
for(int i = 8; i>=0; i--)
{
s_tab_view->setCurrentPage(i); // s_tab_view: QTabView
QPixmap peakPixmap;
QString pixMapFileName = "C:\\pinPostDoc\\" + dateQString + "_" +
s_tab_view->label(i).remove('&') + ".png";
Sleep(500);
peakPixmap = QPixmap::grabWidget(s_tab_view, 0, 0, -1, -1);
beakPixmap.save(pixMapFileName, "PNG");
}
Bookmarks