Important: Please read the Qt Code of Conduct -

Do I need QApllication instance for QPainter, QImage?

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

  • Moderators

    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.

  • Lifetime Qt Champion


    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

Log in to reply