[Solved] QPrinter crash on Qt5
-
Hi, i need help...
i write small program to print receipt. but having difficulties with Qt5. It always crash. in Qt4 it working just fine. So i decide to test it, here is the code:@#include <QCoreApplication>
#include <QPrinter>
#include <QPainter>int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);QPrinter printer; printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFileName("test.pdf"); QPainter p; if (p.begin(&printer)) { p.drawText(0, 0, "test"); p.end(); } return 0;
}@
in Qt5 if i replace drawText with drawLine, crash didn't happen. Tested on Qt 5.3.1 MSVC 2013 and Qt 5.2.1 MSVC 2010, Qt 4.8.6 MSVC 2010. What is wrong with my code? Can someone give me a hint about the proper way to use QPrinter on Qt5. I'm just newbie on programming...
Thank you. Sorry for my bad english. -
Hi and welcome to devnet,
IIRC you must use a QApplication