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. QtGUI::QApplication and QtCore::QCoreApplication::init() ?
Forum Updated to NodeBB v4.3 + New Features

QtGUI::QApplication and QtCore::QCoreApplication::init() ?

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 7.3k 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.
  • A Offline
    A Offline
    abrakadobr
    wrote on last edited by
    #1

    as i'm looking by sources of Qt - when i create object of QtGui::QApplication class method QtCore::QCoreApplication::init() must run.
    but really i don't understand - it runs or not?
    i rewrite function qt_startup_hook with my own code (QMessageBox::information), but this code not runs when i start any compiled application with my new QtCore4.dll
    why? =)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Santosh Reddy
      wrote on last edited by
      #2

      init() is the first thing done in QCoreApplication constructor and
      qt_startup_hook() is the last thing done in QCoreApplication constructor
      More over QApplication is not fully constructed when qt_startup_hook() is called, only QCoreApplication part of QApplication is constructed, so your QMessageBox::information will not work.

      SS

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        Run the message box from your main function after QApplication has been constructed.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • A Offline
          A Offline
          abrakadobr
          wrote on last edited by
          #4

          Santosh, thanx for answer, Volker - you didn't got what i'm doing.
          so i changed QMessageBox to WINAPI MessageBox, but still nothing.
          i'm looking with disasembler - no using of qt_startup_hook() function =(

          1 Reply Last reply
          0
          • A Offline
            A Offline
            abrakadobr
            wrote on last edited by
            #5

            also i'm disasembling original QtCore4.dll - nothing uses qt_startup_hook function.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              What are you trying to do within that hook? It must be some very super-specific magic code if it cannot wait until the constructor of the QApplication object returns...

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • A Offline
                A Offline
                abrakadobr
                wrote on last edited by
                #7

                i'm making gui testing utility.
                main idea i got from "here":http://www.koders.com/cpp/fidB1388BB4BB0D095F7B0240654A4F11A08ACA5C13.aspx?s=“Reinhart”#L2 and now implementing it, but code not working.

                when i'll run it - i can test any Qt application without adding any code to testing app - i will have my special QtCore.dll with testing code.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  abrakadobr
                  wrote on last edited by
                  #8

                  and again no answers =(
                  as i got from source code, QCoreApplication::init() is using only for console applications, yep?
                  @/*!
                  Constructs a Qt kernel application. Kernel applications are
                  applications without a graphical user interface. These type of
                  applications are used at the console or as server processes.

                  The \a argc and \a argv arguments are processed by the application,
                  and made available in a more convenient form by the arguments()
                  function.
                  
                  \warning The data referred to by \a argc and \a argv must stay valid
                  for the entire lifetime of the QCoreApplication object. In addition,
                  \a argc must be greater than zero and \a argv must contain at least
                  one valid character string.
                  

                  */
                  QCoreApplication::QCoreApplication(int &argc, char **argv)
                  : QObject(*new QCoreApplicationPrivate(argc, argv))
                  {
                  init();
                  QCoreApplicationPrivate::eventDispatcher->startingUp();
                  #if defined(Q_OS_SYMBIAN) && !defined(QT_NO_LIBRARY)
                  // Refresh factoryloader, as text codecs are requested during lib path
                  // resolving process and won't be therefore properly loaded.
                  // Unknown if this is symbian specific issue.
                  QFactoryLoader::refreshAll();
                  #endif

                  #if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
                  d_func()->symbianInit();
                  #endif
                  }@

                  so QApplication for GUI applications not uses init() method, and at_startup_hook() ?

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    No.

                    All QApplication constructors call a QCoreApplication constructor which in trun calls init().

                    qt_startup_hook is implemented in qcoreapplication.cpp - I don't know how one is supposed to replace the object code for that with one's own version. It does not help to make a [[Doc:QApplication]] or [[Doc:QCoreApplication]] subclass, as qt_startup_hook is an extern "C" function and therefore is not subject to method polymorphism!

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    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