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. qInstallMessageHandler vs. QApplication: order of creation
Forum Updated to NodeBB v4.3 + New Features

qInstallMessageHandler vs. QApplication: order of creation

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 332 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.
  • R Offline
    R Offline
    Robert Hairgrove
    wrote on last edited by
    #1

    In the Qt documentation of qInstallMessageHandler, there is a little example given where this is called BEFORE the application object is created:

    int main(int argc, char **argv)
     {
         qInstallMessageHandler(myMessageOutput);
         QApplication app(argc, argv);
         ...
         return app.exec();
     }
    

    Is this the required or recommended order? The rest of the documentation doesn't seem to offer an explanation. For almost everything else, it always seems to be necessary to create the application first.

    I suppose that the constructor of app might issue warnings, but that is highly unlikely.

    JonBJ 1 Reply Last reply
    0
    • R Robert Hairgrove

      In the Qt documentation of qInstallMessageHandler, there is a little example given where this is called BEFORE the application object is created:

      int main(int argc, char **argv)
       {
           qInstallMessageHandler(myMessageOutput);
           QApplication app(argc, argv);
           ...
           return app.exec();
       }
      

      Is this the required or recommended order? The rest of the documentation doesn't seem to offer an explanation. For almost everything else, it always seems to be necessary to create the application first.

      I suppose that the constructor of app might issue warnings, but that is highly unlikely.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Robert-Hairgrove
      I don't think it matters. I certainly have done qInstallMessageHandler() not as the first statement in my program, rather much later well after QApplication app(argc, argv).

      R 1 Reply Last reply
      2
      • JonBJ JonB

        @Robert-Hairgrove
        I don't think it matters. I certainly have done qInstallMessageHandler() not as the first statement in my program, rather much later well after QApplication app(argc, argv).

        R Offline
        R Offline
        Robert Hairgrove
        wrote on last edited by
        #3

        @JonB Thanks!

        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