You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, June 5th 2013, 2:09pm

Problem with QPrinter

Hi everybody !

I'm coding an app using QPrinter to print PDF files. This app worked well on my old server but on the new one, it abort :cursing:
I searched on many forums but I didn't find any solution...
The programm abord when the object QPrinter is instanciated (Sorry, I'm french ...).
I thought it could be a library problem but Qt4 and Qt3_Support libraries are installed on the new server.

So .. I'm lost !!! I need help ! Someone has an idea ?
Thanks for you help !

Source code

1
2
3
4
5
6
7
8
9
10
# test.pro
QT       += core

TARGET = test
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Main.cpp
#include <QtCore/QCoreApplication>
#include <Qt/qprinter.h>

using namespace std;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QPrinter printer(QPrinter::HighResolution); // ---> It abord here <---
    printer.setOutputFileName("test_QPrinter.pdf");
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setColorMode(QPrinter::Color);
    printer.setCreator(QString("MasterCreator"));
    printer.setOrientation(QPrinter::Portrait);
    printer.setFullPage(true);
    printer.setDocName("View_my_PDF_file");
    return a.exec();
}

2

Wednesday, June 5th 2013, 4:31pm

Ok, I found a solution ... Even more a reason that it doesn't work.
Since Qt 4.4.3 , QPrinter have to use a X11 server connection and my server does not have this ....