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. Verify " globally accesible " qApp
Qt 6.11 is out! See what's new in the release blog

Verify " globally accesible " qApp

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 331 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    Using an option to restart the discussion instead to continue the stale one - just Before somebody will complain about the dupe.

    The older post somehow skipped HOW "qApp" became ONE and ONLY ONLY ONE GLOBAL value.

    BTW -it also misrepresented QApplication and QCoreApplication - with or without "event loop". Not related to "qApp" pointer.

    Re: [SOLVED] Which method of the main Widget returns the QApplication instance?

    kshegunovK 1 Reply Last reply
    0
    • A Anonymous_Banned275

      Using an option to restart the discussion instead to continue the stale one - just Before somebody will complain about the dupe.

      The older post somehow skipped HOW "qApp" became ONE and ONLY ONLY ONE GLOBAL value.

      BTW -it also misrepresented QApplication and QCoreApplication - with or without "event loop". Not related to "qApp" pointer.

      Re: [SOLVED] Which method of the main Widget returns the QApplication instance?

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      @AnneRanch said in Verify " globally accesible " qApp:

      The older post somehow skipped HOW "qApp" became ONE and ONLY ONLY ONE GLOBAL value.

      It became the one and only one global value by means of you creating it - the one and only one QCoreApplication instance you create in main(). There's no magic, the object sets a global pointer inside its constructor and gives that value back to you when requested through QCoreApplication::instance(). qApp is just a convenience macro that calls QCoreApplication::instance.

      PS. The relevant code: https://code.woboq.org/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp.html#_ZN23QCoreApplicationPrivate4initEv

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      2

      • Login

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