Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Do I need QApllication instance for QPainter, QImage?

    General and Desktop
    3
    3
    587
    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
      stima_ua last edited by

      I need only some core things that aren't related to loop. Do I need QApplication for them?

      1 Reply Last reply Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        In general you need Q*Application for anything that is derived from QObject.
        I'm not sure but I would risk to say QImage might not need it. QPainter probably does, as it uses some platform specific stuff that might require some system state management handled by Q*Application.

        A worth noting is that you don't need to start a loop (i.e. call exec()) to have a Q*Application instance so if you're not gonna use functionality requiring a loop just don't start it, but do create the instance.

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

          Hi,

          Yes you do, there's some internal setup that's done with QApplication that are needed. However in Qt 4, you have the option to pass a boolean value as third parameter of the constructor to disable the GUI part so you can make a console application using some of the GUI related class

          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
          • First post
            Last post