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. QQmlApplicationEngine engine slow to construct after installing custom message handler
Forum Updated to NodeBB v4.3 + New Features

QQmlApplicationEngine engine slow to construct after installing custom message handler

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 413 Views
  • 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.
  • Chris_1981C Offline
    Chris_1981C Offline
    Chris_1981
    wrote on last edited by Chris_1981
    #1

    Calling QQmlApplicationEngine engine; needs around 8 seconds, if qInstallMessageHandler(myMessageOutput); is called before.
    Without calling qInstallMessageHandler(myMessageOutput); it needs around 400 milliseconds. Used version is Desktop_Qt_5_6_0_MSVC2015_64bit-Debug.

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QElapsedTimer>
    
    void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
    {
      return;
    }
    
    int main(int argc, char *argv[])
    {
      QGuiApplication app(argc, argv);
      
      qInstallMessageHandler(myMessageOutput); 
      
      QElapsedTimer timer;
      timer.start();
      QQmlApplicationEngine engine; // This line takes around 8 seconds. But without calling qInstallMessageHandler, it takes around 400 milliseconds. Why? 
      qint64 elapsed = timer.elapsed();
    
      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
      return app.exec();
    }
    
    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