I am trying to launch an example of creating a notebook from Qt tutorials ( https://doc.qt.io/qt-5/qtwidgets-tutorials-notepad-example.html ) without QtCreator.
In the constructor
Notepad::Notepad(QWidget* parent) : QMainWindow(parent), ui(new Ui::Notepad) { ui->setupUi(this); this->setCentralWidget(ui->textEdit); connect(ui->actionNew, &QAction::triggered, this, &Notepad::newDocument); connect(ui->actionOpen, &QAction::triggered, this, &Notepad::open); connect(ui->actionSave, &QAction::triggered, this, &Notepad::save); connect(ui->actionSave_as, &QAction::triggered, this, &Notepad::saveAs); connect(ui->actionPrint, &QAction::triggered, this, &Notepad::print); connect(ui->actionExit, &QAction::triggered, this, &Notepad::exit); connect(ui->actionCopy, &QAction::triggered, this, &Notepad::copy); connect(ui->actionCut, &QAction::triggered, this, &Notepad::cut); connect(ui->actionPaste, &QAction::triggered, this, &Notepad::paste); connect(ui->actionUndo, &QAction::triggered, this, &Notepad::undo); connect(ui->actionRedo, &QAction::triggered, this, &Notepad::redo); connect(ui->actionFont, &QAction::triggered, this, &Notepad::selectFont); connect(ui->actionBold, &QAction::triggered, this, &Notepad::setFontBold); connect(ui->actionUnderline, &QAction::triggered, this, &Notepad::setFontUnderline); connect(ui->actionItalic, &QAction::triggered, this, &Notepad::setFontItalic); connect(ui->actionAbout, &QAction::triggered, this, &Notepad::about); // Disable menu actions for unavailable features #if !QT_CONFIG(printer) ui->actionPrint->setEnabled(false); #endif #if !QT_CONFIG(clipboard) ui->actionCut->setEnabled(false); ui->actionCopy->setEnabled(false); ui->actionPaste->setEnabled(false); #endif } in macro
// Disable menu actions for unavailable features #if !QT_CONFIG(printer) ui->actionPrint->setEnabled(false); #endif getting
error: division by zero in #if! QT_CONFIG (printer)
Apparently, this is due to the fact that the following chain of inclusions does not work
#if defined(QT_PRINTSUPPORT_LIB) #include <QtPrintSupport/qtprintsupportglobal.h> #if QT_CONFIG(printer) #if QT_CONFIG(printdialog) #include <QPrintDialog> #endif // QT_CONFIG(printdialog) #include <QPrinter> #endif // QT_CONFIG(printer) #endif // QT_PRINTSUPPORT_LIB How can I fix the example so that it works without installing a library for printing (QT_PRINTSUPPORT_LIB)?