![]() If you want more help from here you should also post a more complete code sample.Īlso what version of Qt, and the OS you are using would be helpful. If you did not define the painter as a member function that would have happened when the painter when out of scope.Īs said you should debug your code to see where it is crashing. Next assuming you get past that you should add m_painter.end() to the end of the print function so you can actually see what you draw on the paper in the preview. you don't have printer set up properly the behaviour will be undefined and might be the reason for the crash. If this is the case then you should test that the printer is valid before you use it with the painter in the print function. I am assuming your MyPrinter class is derived from a QWidget, although this is not clear from your code snippets, and assuming you have actually defined the print function as a slot. Must have a QPrinter pointer for the SIGNAL function as in SIGNAL(paintRequested(QPrinter*)). connect(printPreviewDialog,SIGNAL(paintRequested(QPrinter)),this,SLOT(print(QPrinter*))) There are several problems with the code you pasted, I am surprised it even compiles, for example. M_painter.drawText(rect, Qt::AlignLeft, "Created at: " + time) // assume rect, time is If you are still interested in an answer to this question. If (printPreviewDialog->exec() != QDialog::Accepted) ![]() QPrintPreviewDialog printPreviewDialog = new QPrintPreviewDialog(&m_printer, pParent) Ĭonnect(printPreviewDialog,SIGNAL(paintRequested(QPrinter)),this,SLOT(print(QPrinter*))) Is there any known bug with QPrintPreviewDialog in Qt version 5.6.1 ?īelow is the implementation I am trying to test.īool MyPrinter:: openPrintPreviewDialog(QWidget* parent) My application crashes when I select print button inside PrintPreview dialog.
0 Comments
Leave a Reply. |