File tree Expand file tree Collapse file tree 2 files changed +18
-11
lines changed
Expand file tree Collapse file tree 2 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 1313#include < QAction>
1414#include < QMenu>
1515#include < QPalette>
16- #include < QPrintDialog >
16+ #include < QPrintPreviewDialog >
1717#include < cmath>
1818
1919
@@ -246,11 +246,15 @@ void ExtendedScintilla::showContextMenu(const QPoint &pos)
246246
247247void ExtendedScintilla::openPrintDialog ()
248248{
249- QsciPrinter* printer = new QsciPrinter;
249+ QsciPrinter printer;
250+ QPrintPreviewDialog *dialog = new QPrintPreviewDialog (&printer);
250251
251- QPrintDialog printDialog (printer, this );
252- if (printDialog.exec () == QDialog::Accepted)
253- printer->printRange (this );
252+ connect (dialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter *previewPrinter) {
253+ QsciPrinter* sciPrinter = static_cast <QsciPrinter*>(previewPrinter);
254+ sciPrinter->printRange (this );
255+ });
254256
255- delete printer;
257+ dialog->exec ();
258+
259+ delete dialog;
256260}
Original file line number Diff line number Diff line change 1717#include < QDateTime>
1818#include < QLineEdit>
1919#include < QPrinter>
20- #include < QPrintDialog >
20+ #include < QPrintPreviewDialog >
2121#include < QTextDocument>
2222#include < QCompleter>
2323
@@ -874,12 +874,15 @@ void ExtendedTableWidget::openPrintDialog()
874874 document->setHtml (mimeData->html ());
875875
876876 QPrinter printer;
877+ QPrintPreviewDialog *dialog = new QPrintPreviewDialog (&printer);
877878
878- QPrintDialog *dialog = new QPrintDialog (&printer, nullptr );
879- if (dialog->exec () == QDialog::Accepted) {
880- document->print (&printer);
881- }
879+ connect (dialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter *previewPrinter) {
880+ document->print (previewPrinter);
881+ });
882+
883+ dialog->exec ();
882884
885+ delete dialog;
883886 delete document;
884887 delete mimeData;
885888}
You can’t perform that action at this time.
0 commit comments