diff --git a/examples/widgets/itemviews/spreadsheet/printview.cpp b/examples/widgets/itemviews/spreadsheet/printview.cpp index 7db1a6bad9..7700b4ed6a 100644 --- a/examples/widgets/itemviews/spreadsheet/printview.cpp +++ b/examples/widgets/itemviews/spreadsheet/printview.cpp @@ -50,8 +50,12 @@ #include "printview.h" -#ifndef QT_NO_PRINTER -#include +#if defined(QT_PRINTSUPPORT_LIB) +# include + +# if QT_CONFIG(printer) +# include +# endif #endif PrintView::PrintView() @@ -62,9 +66,11 @@ PrintView::PrintView() void PrintView::print(QPrinter *printer) { -#ifndef QT_NO_PRINTER +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) resize(printer->width(), printer->height()); render(printer); +#else + Q_UNUSED(printer) #endif } diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp b/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp index fc7fbb872c..ac8ea7d437 100644 --- a/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp +++ b/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp @@ -638,7 +638,7 @@ QString encode_pos(int row, int col) void SpreadSheet::print() { -#if QT_CONFIG(printpreviewdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog) QPrinter printer(QPrinter::ScreenResolution); QPrintPreviewDialog dlg(&printer); PrintView view; diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index 7708b25a24..c9173bcb99 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -197,7 +197,7 @@ void TextEdit::setupFileActions() a->setPriority(QAction::LowPriority); menu->addSeparator(); -#ifndef QT_NO_PRINTER +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) const QIcon printIcon = QIcon::fromTheme("document-print", QIcon(rsrcPath + "/fileprint.png")); a = menu->addAction(printIcon, tr("&Print..."), this, &TextEdit::filePrint); a->setPriority(QAction::LowPriority); @@ -559,7 +559,7 @@ void TextEdit::filePrint() void TextEdit::filePrintPreview() { -#if QT_CONFIG(printpreviewdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog) QPrinter printer(QPrinter::HighResolution); QPrintPreviewDialog preview(&printer, this); connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TextEdit::printPreview); @@ -569,17 +569,17 @@ void TextEdit::filePrintPreview() void TextEdit::printPreview(QPrinter *printer) { -#ifdef QT_NO_PRINTER - Q_UNUSED(printer); -#else +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) textEdit->print(printer); +#else + Q_UNUSED(printer) #endif } void TextEdit::filePrintPdf() { -#ifndef QT_NO_PRINTER +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) //! [0] QFileDialog fileDialog(this, tr("Export PDF")); fileDialog.setAcceptMode(QFileDialog::AcceptSave); diff --git a/examples/widgets/tutorials/notepad/notepad.pro b/examples/widgets/tutorials/notepad/notepad.pro index 6451f22735..efe16fc2a2 100644 --- a/examples/widgets/tutorials/notepad/notepad.pro +++ b/examples/widgets/tutorials/notepad/notepad.pro @@ -1,6 +1,8 @@ TEMPLATE = app TARGET = notepad +QT += widgets + qtHaveModule(printsupport): QT += printsupport requires(qtConfig(fontdialog)) diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp index 70a4cda984..1ed55ca6cb 100644 --- a/examples/widgets/widgets/imageviewer/imageviewer.cpp +++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp @@ -69,10 +69,11 @@ #include #if defined(QT_PRINTSUPPORT_LIB) -#include -#if QT_CONFIG(printdialog) -#include -#endif +# include + +# if QT_CONFIG(printdialog) +# include +# endif #endif //! [0] diff --git a/examples/widgets/widgets/imageviewer/imageviewer.h b/examples/widgets/widgets/imageviewer/imageviewer.h index 49c7ac205b..9c8388d470 100644 --- a/examples/widgets/widgets/imageviewer/imageviewer.h +++ b/examples/widgets/widgets/imageviewer/imageviewer.h @@ -53,8 +53,12 @@ #include #include -#ifndef QT_NO_PRINTER -#include +#if defined(QT_PRINTSUPPORT_LIB) +# include + +# if QT_CONFIG(printer) +# include +# endif #endif QT_BEGIN_NAMESPACE @@ -100,7 +104,7 @@ private: QScrollArea *scrollArea; double scaleFactor = 1; -#ifndef QT_NO_PRINTER +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) QPrinter printer; #endif