Problem with printing
-
Hi all,
I am trying to print a QTableWidget with QPrinter. When I add #include <QPrinter> the compiler complains that this header does not exist. I found a QPrinter header in <QtPrintSupport/QPrinter> but if I use that then the linker complains "Symbol not found for architecture x86_64. I am using MacBook pro and I also installed the full package of QT. Here is the piece of code I am trying to use (It is completely from documentation with little change)
@ QPainter painter;
QPrinter printer;
painter.begin(printer);
double xscale = printer.pageRect().width()/double(ui->tableStatics->width());
double yscale = printer.pageRect().height()/double(ui->tableStatics->height());
double scale = qMin(xscale, yscale);
painter.translate(printer.paperRect().x() + printer.pageRect().width()/2,
printer.paperRect().y() + printer.pageRect().height()/2);
painter.scale(scale, scale);
painter.translate(-width()/2, -height()/2);ui->tableStatics->render(painter);@
Any help is appreciated.
-
Add the "QT += printsupport" to your .pro file.
"source":http://qt-project.org/doc/qt-5.0/qtprintsupport/qtprintsupport-module.html