Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPrinter problem in Qt-5.13.0 with Xcode 10.3

QPrinter problem in Qt-5.13.0 with Xcode 10.3

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 498 Views
  • 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 Offline
    S Offline
    Spacehopper
    wrote on last edited by
    #1

    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
    0
    • S Offline
      S Offline
      Spacehopper
      wrote on last edited by
      #4

      Ah ha!

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

      All sorted now.

      1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        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
        0
        • S Offline
          S Offline
          Spacehopper
          wrote on last edited by
          #3

          @SGaist

          Hi,

          Yes:

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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Spacehopper
            wrote on last edited by
            #4

            Ah ha!

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

            All sorted now.

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved