Examples: fix compile without printsupport

Checking for QT_CONFIG(printdialog) is not enough when printsupport is
completely disabled since then the macro will throw an error. Therefore
add an additional check 'defined(QT_PRINTSUPPORT_LIB)' before using the
QT_CONFIG macro.

Fixes: QTBUG-81626
Change-Id: Ie9898f057cdd6bf9daf4ba9135987cb6e901e7bf
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Christian Ehrlicher 2020-01-29 19:58:01 +01:00
parent 9ede07613d
commit c7f59cad19
10 changed files with 11 additions and 11 deletions

View File

@ -369,7 +369,7 @@ void ConclusionPage::setVisible(bool visible)
void ConclusionPage::printButtonClicked()
{
#if QT_CONFIG(printdialog)
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QPrinter printer;
QPrintDialog dialog(&printer, this);
if (dialog.exec())

View File

@ -264,7 +264,7 @@ void View::toggleAntialiasing()
void View::print()
{
#if QT_CONFIG(printdialog)
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QPrinter printer;
QPrintDialog dialog(&printer, this);
if (dialog.exec() == QDialog::Accepted) {

View File

@ -167,7 +167,7 @@ void MainWindow::openImage(const QString &fileName)
void MainWindow::printImage()
{
#if QT_CONFIG(printdialog)
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
if (model->rowCount(QModelIndex())*model->columnCount(QModelIndex()) > 90000) {
QMessageBox::StandardButton answer;
answer = QMessageBox::question(this, tr("Large Image Size"),

View File

@ -128,7 +128,7 @@ void MainWindow::newLetter()
//! [3]
void MainWindow::print()
{
#if QT_CONFIG(printdialog)
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QTextDocument *document = textEdit->document();
QPrinter printer;

View File

@ -248,7 +248,7 @@ void MainWindow::openDialog()
//! [17]
void MainWindow::printFile()
{
#if QT_CONFIG(printdialog)
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QTextEdit *editor = static_cast<QTextEdit*>(letters->currentWidget());
//! [18]
QPrinter printer;

View File

@ -545,7 +545,7 @@ bool TextEdit::fileSaveAs()
void TextEdit::filePrint()
{
#if QT_CONFIG(printdialog)
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QPrinter printer(QPrinter::HighResolution);
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (textEdit->textCursor().hasSelection())

View File

@ -170,7 +170,7 @@ void ScribbleArea::resizeImage(QImage *image, const QSize &newSize)
//! [21]
void ScribbleArea::print()
{
#if QT_CONFIG(printdialog)
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QPrinter printer(QPrinter::HighResolution);
QPrintDialog printDialog(&printer, this);

View File

@ -92,7 +92,7 @@ Notepad::Notepad(QWidget *parent) :
connect(ui->actionAbout, &QAction::triggered, this, &Notepad::about);
// Disable menu actions for unavailable features
#if !QT_CONFIG(printer)
#if !defined(QT_PRINTSUPPORT_LIB) || !QT_CONFIG(printer)
ui->actionPrint->setEnabled(false);
#endif
@ -171,7 +171,7 @@ void Notepad::saveAs()
void Notepad::print()
{
#if QT_CONFIG(printer)
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
QPrinter printDev;
#if QT_CONFIG(printdialog)
QPrintDialog dialog(&printDev, this);

View File

@ -201,7 +201,7 @@ void ImageViewer::print()
//! [5] //! [6]
{
Q_ASSERT(imageLabel->pixmap());
#if QT_CONFIG(printdialog)
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
//! [6] //! [7]
QPrintDialog dialog(&printer, this);
//! [7] //! [8]

View File

@ -210,7 +210,7 @@ void ScribbleArea::resizeImage(QImage *image, const QSize &newSize)
//! [21]
void ScribbleArea::print()
{
#if QT_CONFIG(printdialog)
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QPrinter printer(QPrinter::HighResolution);
QPrintDialog printDialog(&printer, this);