Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QPrinter problem in Qt-5.13.0 with Xcode 10.3

    General and Desktop
    2
    4
    225
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Spacehopper last edited by

      Hi

      I've just resurrected a piece of software I wrote a couple of years ago. It worked back then under Qt-5.5 (I think). Now I'm getting error messages relating to "Unknown type name 'QPrinter'" under Qt-5.13.0.

      Here is the code fragment with the error messages inserted alongside the code and preceded by an *:

      ...

      #include <QPrinter>
      #include <QPrinterInfo>

      void MainWindow::printHints(Grid *p)
      {
      QPrinterInfo printer; *Unknown type name 'QPrinterInfo'
      int row, col, n, bit;

      if (printer.defaultPrinter().isNull()) {
      statusBar()->showMessage(tr("No printer available."));
      return;
      }
      QPrinter hints; *Unknown type name 'QPrinter'; did you mean 'QPainter'?
      hints.setPageOrientation(QPageLayout::Landscape); *No member named 'setPageOrientation' in 'QPainter'

      QFont printfont("courier", 10);
      printfont.setFixedPitch(true);

      QPainter painter;
      painter.begin(&hints); *Cannot initialize a parameter of type 'QPaintDevice *' with an rvalue of type 'QPainter *'
      ...

      Can anyone explain why QPrinter & QPrinterInfo are unknown types please?

      1 Reply Last reply Reply Quote 0
      • S
        Spacehopper last edited by

        Ah ha!

        Solved. I was using the wrong version of qmake to build the project.

        All sorted now.

        1 Reply Last reply Reply Quote 2
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi and welcome to devnet,

          Do you have QT += printsupport in your .pro file ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 0
          • S
            Spacehopper last edited by

            @SGaist

            Hi,

            Yes:

            ...
            QT += widgets
            QT += printsupport
            QT += gui
            ...

            1 Reply Last reply Reply Quote 0
            • S
              Spacehopper last edited by

              Ah ha!

              Solved. I was using the wrong version of qmake to build the project.

              All sorted now.

              1 Reply Last reply Reply Quote 2
              • First post
                Last post