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

  • 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? =)

  • 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.

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

  • 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 =(

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

  • 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...

  • 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.

  • 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()
    \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))
    #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.

    #if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)

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

  • 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!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.