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. Qt library must construct QGuiApplication, when it runs "should be only 1 app object"
Forum Updated to NodeBB v4.3 + New Features

Qt library must construct QGuiApplication, when it runs "should be only 1 app object"

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.0k Views 2 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.
  • P Offline
    P Offline
    pedromarquesmm
    wrote on last edited by pedromarquesmm
    #1

    Hello!

    I made a very simple library, with just one function in it, that requires other Qt libraries, like pixelmap, painter etc...
    So far so good, when running it and building the .lib file with Visual Studio 2017 it compiles perfectly, also when using the function in another solution.

    I start the function constructing a QGuiApplication object (also have a problem with the argv and argc in a program that does not have a main function), and on the end of the function I run "exit()" on the QGuiApp object.

    When running on the machine I built the solution in, it works fine, but when running the .exe on another computer, without Qt, but with all the DLL's files besides the .exe file, It throws a Microsoft Visual C++ Runtime Library error, with the message "QCoreApplication: there should be only one application object, file kernel\qcoreapplication.cpp"

    Eventhough QPixmap requires a QGuiApplication, is there any solution?

    Thank you all for your time.

    jsulmJ 1 Reply Last reply
    0
    • P pedromarquesmm

      Hello!

      I made a very simple library, with just one function in it, that requires other Qt libraries, like pixelmap, painter etc...
      So far so good, when running it and building the .lib file with Visual Studio 2017 it compiles perfectly, also when using the function in another solution.

      I start the function constructing a QGuiApplication object (also have a problem with the argv and argc in a program that does not have a main function), and on the end of the function I run "exit()" on the QGuiApp object.

      When running on the machine I built the solution in, it works fine, but when running the .exe on another computer, without Qt, but with all the DLL's files besides the .exe file, It throws a Microsoft Visual C++ Runtime Library error, with the message "QCoreApplication: there should be only one application object, file kernel\qcoreapplication.cpp"

      Eventhough QPixmap requires a QGuiApplication, is there any solution?

      Thank you all for your time.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @pedromarquesmm Is it exactly the same app you're running on the other machine?
      It sounds like you have more than one QApplication instance (one in the app and one in the lib).

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pedromarquesmm
        wrote on last edited by pedromarquesmm
        #3

        in the main app (where I call Qt function), I don't create any app. trust me, in what code matters, I only have 1 QApplication... That's why I can't really understand why it throws me that error.

        In the main solution, where I call the lib's function, I don't even have Qt libraries included, it's all on the lib

        And yes, the app is exactly the same, everything copied together. just had to add "platforms\qwindowsd.dll" in order to run

        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