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. Looking for help with QPrinter

Looking for help with QPrinter

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 824 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
    Stewguy
    wrote on last edited by
    #1

    Hello there.

    I'm struggling to get QPrinter to work in my project and I'm hoping someone can point me in the right direction.

    When I build the project I get "'QPrinter' was not declared in this scope". That's basically all I get for errors.

    Within my .cpp file where I'm making a QPrinter object I have:
    #include <QPrinter>

    In my .pro file I have:
    QT += printsupport

    Does anyone have any tips around what I can try to debug this?

    J.HilkJ JonBJ 2 Replies Last reply
    0
    • S Stewguy

      Hello there.

      I'm struggling to get QPrinter to work in my project and I'm hoping someone can point me in the right direction.

      When I build the project I get "'QPrinter' was not declared in this scope". That's basically all I get for errors.

      Within my .cpp file where I'm making a QPrinter object I have:
      #include <QPrinter>

      In my .pro file I have:
      QT += printsupport

      Does anyone have any tips around what I can try to debug this?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Stewguy said in Looking for help with QPrinter:

      QPrinter

      Hi,

      first of, did you rerun qmake / delete your build folder for a clean rebuild after adding QT += printsupport ?
      this is the most common error people have

      second,
      for what platform do you try to use the modul for, IIRC I tried to use it to create a pdf on mobile devices and I had to fall back to QPdfWriter


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3
      • S Stewguy

        Hello there.

        I'm struggling to get QPrinter to work in my project and I'm hoping someone can point me in the right direction.

        When I build the project I get "'QPrinter' was not declared in this scope". That's basically all I get for errors.

        Within my .cpp file where I'm making a QPrinter object I have:
        #include <QPrinter>

        In my .pro file I have:
        QT += printsupport

        Does anyone have any tips around what I can try to debug this?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Stewguy
        After you have acted on @J-Hilk 's comments, your code does not in itself show where you actually attempt to use QPrinter?

        1 Reply Last reply
        1
        • A Offline
          A Offline
          Asperamanca
          wrote on last edited by
          #4

          You could try out one of the examples that uses QPrinter, e.g. the Font Sampler. If you have trouble there as well, it's probably a system or Qt configuration issue. If not, it's probably something in your project.

          S 1 Reply Last reply
          3
          • A Asperamanca

            You could try out one of the examples that uses QPrinter, e.g. the Font Sampler. If you have trouble there as well, it's probably a system or Qt configuration issue. If not, it's probably something in your project.

            S Offline
            S Offline
            Stewguy
            wrote on last edited by
            #5

            @Asperamanca said in Looking for help with QPrinter:

            You could try out one of the examples that uses QPrinter, e.g. the Font Sampler. If you have trouble there as well, it's probably a system or Qt configuration issue. If not, it's probably something in your project.

            Thanks for pointing out the example, it ended up leading me to the solution.

            What resolved it:

            The QT template added the following lines into my .pro file

            INCLUDEPATH += $$PWD/../../../../Qt/5.11.0/winrt_x86_msvc2017/include
            DEPENDPATH += $$PWD/../../../../Qt/5.11.0/winrt_x86_msvc2017/include

            Something about those was causing QPrinter not to load. Once I removed those lines the project was able to Build and Run.

            Thanks for the help everyone!

            1 Reply Last reply
            1

            • Login

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