yes, nice idea, thank you.
so far, i've tried the following:
void THIS::printX() {
tempXPixmap->grabWidget(xLabel);
if (dialog.exec()) {
QRect rect
= painter.
viewport();
QSize size
= tempXPixmap
->size
();
size.scale(rect.size(), Qt::KeepAspectRatio);
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
painter.setWindow(tempXPixmap->rect());
painter.drawPixmap(0, 0, *tempXPixmap);
}
}
void THIS::printX() {
QPrintDialog dialog(&printer, this);
QPixmap* tempXPixmap = new QPixmap;
tempXPixmap->grabWidget(xLabel);
if (dialog.exec()) {
QPainter painter(&printer);
QRect rect = painter.viewport();
QSize size = tempXPixmap->size();
size.scale(rect.size(), Qt::KeepAspectRatio);
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
painter.setWindow(tempXPixmap->rect());
painter.drawPixmap(0, 0, *tempXPixmap);
}
}
To copy to clipboard, switch view to plain text mode
this results in a segmentation fault..
gdb backtrace:
(gdb) backtrace
#0 0xb61bc8f7 in __divdi3 () from /lib/libgcc_s.so.1
#1 0xb62a8c0a in QSize:: scale () from /usr/lib/libQtCore.so.4
#2 0x080ba2d2 in MainWindow:: printX ()
#3 0x080f0a4d in MainWindow:: qt_metacall ()
#4 0xb6330aa8 in QMetaObject:: activate () from /usr/lib/libQtCore.so.4
#5 0xb6330d2f in QMetaObject:: activate () from /usr/lib/libQtCore.so.4
#6 0xb64bf831 in QAction:: triggered () from /usr/lib/libQtGui.so.4
#7 0xb64c01bf in QAction:: activate () from /usr/lib/libQtGui.so.4
#8 0xb67c6fd4 in ?? () from /usr/lib/libQtGui.so.4
.....
so why doesn't the scale work? i used this method to print other pixmaps, is there a problem with the grabWidget() ?
Bookmarks