PDA

View Full Version : Qt - Simple code QPrinter doesn't work on others pc



dexter87
30th April 2015, 17:25
Hi all, i have a little problem with this simple code:


void MainWindow::on_Stampa_clicked()

{

QPrinter printer(QPrinter::HighResolution);

printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Portrait);
printer.setPageMargins (15,15,15,15,QPrinter::Millimeter);
printer.setFullPage(false);
printer.setOutputFormat(QPrinter::NativeFormat);


QPainter painter(&printer);

painter.setFont(QFont("Tahoma",8));
painter.drawText(200,200,"Test prova prova");
painter.end();

}

"Stampa" is a normal button.

In the PC with QT the print works right, but in the others pc (one with win 8.1 and one with win 7) default print doesn't start, the print queue stay empty. I don't understand why and i don't get any error.

I use:


#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPrinter>
#include <QPainter>

and in the .pro:


QT += printsupport
QTPLUGIN += windowsprintersupport

The dll "Qt5PrintSupport" is present inside the folder of course.

Sorry for the noob question but I don't understand what I am doing wrong..

dexter87
1st May 2015, 10:09
Solved with add
{myAppPath}\printsupport\windowsprintersupport.dll

http://stackoverflow.com/questions/29965051/qt-simple-code-qprinter-doesnt-work-on-others-pc/29980565#29980565