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: Must construct a QCoreApplication before a QPrinter

QPrinter: Must construct a QCoreApplication before a QPrinter

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 4.6k Views 1 Watching
  • 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.
  • H Offline
    H Offline
    Harry123
    wrote on last edited by
    #1

    On Windows with Qt version 5.6, the following line causes my program to stop :

    QPrinter * printer = new QPrinter(QPrinter::HighResolution);
    

    With the following message in the debugger's Output window :

    QPrinter: Must construct a QCoreApplication before a QPrinter
    

    Since at the time this happens my application is already long past initialization and the event loop has already treated thousands of events and is certainly not missing, I find this message quite puzzling.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Can you reproduce this in small sample?
      Could just be a 5.6 bug :)

      H 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        Can you reproduce this in small sample?
        Could just be a 5.6 bug :)

        H Offline
        H Offline
        Harry123
        wrote on last edited by
        #3

        @mrjj

        Unfortunately, it cannot be reproduced in a simple project.
        My guess would be some conflict with some system library that I'm linking to.

        For some reason I cannot debug into this line without going into disassembly mode, which is too hopeless.
        Any advice for debugging it?

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          HI
          But do you do anything kinky with the QApplication ?
          or does the system library contains event loops also.
          Else I dont see why it should complain.

          I guess I would look in source to see if I can
          get more information about when it gives this error.

          also go look in bugs system
          https://bugreports.qt.io/browse/QTBUG-43877?jql=text ~ "QPrinter"

          H 1 Reply Last reply
          0
          • mrjjM mrjj

            HI
            But do you do anything kinky with the QApplication ?
            or does the system library contains event loops also.
            Else I dont see why it should complain.

            I guess I would look in source to see if I can
            get more information about when it gives this error.

            also go look in bugs system
            https://bugreports.qt.io/browse/QTBUG-43877?jql=text ~ "QPrinter"

            H Offline
            H Offline
            Harry123
            wrote on last edited by
            #5

            @mrjj

            Found it - yes, I did a kinky thing.

            If anyone ever stumbles upon this one - it comes from linking a debug build with Qt5PrintSupport.lib. A debug build needs to link with Qt5PrintSupportd.lib, or strange things will happen.

            mrjjM 1 Reply Last reply
            1
            • H Harry123

              @mrjj

              Found it - yes, I did a kinky thing.

              If anyone ever stumbles upon this one - it comes from linking a debug build with Qt5PrintSupport.lib. A debug build needs to link with Qt5PrintSupportd.lib, or strange things will happen.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Harry123
              Nice found!

              1 Reply Last reply
              0

              • Login

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