Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QTest: Failing to use QUICK_TEST_MAIN_WITH_SETUP
Forum Updated to NodeBB v4.3 + New Features

QTest: Failing to use QUICK_TEST_MAIN_WITH_SETUP

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
3 Posts 1 Posters 1.2k 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.
  • M Offline
    M Offline
    Marc_Van_Daele
    wrote on last edited by
    #1

    I'm using Qt5.11.2 and I want to use the new QUICK_TEST_MAIN_WITH_SETUP macro. The Setup object is constructed but the slot is never called so I guess I'm doing something wrong.
    When using QML_IMPORT_TRACE=1, I don't see my newly-added import paths either.
    Any ideas?

    I have the following main.cpp (similar to the example on https://doc.qt.io/qt-5.11/qtquicktest-index.html#executing-c-before-qml-tests except for the #include "tst_mytest.moc" at the end since it is unclear to which moc file it refers)

    #include <QtQuickTest>
    #include <QQmlEngine>
    #include <QQmlContext>
    
    class Setup : public QObject
    {
    public:
        Setup()
        {
            qDebug() << "***Setup";
        }
    
    public slots:
        void qmlEngineAvailable(QQmlEngine *engine)
        {
            qDebug() << "***qmlEngineAvailable";
            engine->addImportPath("blablabla");
        }
    };
    
    QUICK_TEST_MAIN_WITH_SETUP(example, Setup)
    
    
    M 1 Reply Last reply
    0
    • M Marc_Van_Daele

      I'm using Qt5.11.2 and I want to use the new QUICK_TEST_MAIN_WITH_SETUP macro. The Setup object is constructed but the slot is never called so I guess I'm doing something wrong.
      When using QML_IMPORT_TRACE=1, I don't see my newly-added import paths either.
      Any ideas?

      I have the following main.cpp (similar to the example on https://doc.qt.io/qt-5.11/qtquicktest-index.html#executing-c-before-qml-tests except for the #include "tst_mytest.moc" at the end since it is unclear to which moc file it refers)

      #include <QtQuickTest>
      #include <QQmlEngine>
      #include <QQmlContext>
      
      class Setup : public QObject
      {
      public:
          Setup()
          {
              qDebug() << "***Setup";
          }
      
      public slots:
          void qmlEngineAvailable(QQmlEngine *engine)
          {
              qDebug() << "***qmlEngineAvailable";
              engine->addImportPath("blablabla");
          }
      };
      
      QUICK_TEST_MAIN_WITH_SETUP(example, Setup)
      
      
      M Offline
      M Offline
      Marc_Van_Daele
      wrote on last edited by Marc_Van_Daele
      #2

      I guess there is a missing Q_OBJECT macro in the example Setup class in https://doc.qt.io/qt-5.11/qtquicktest-index.html#executing-c-before-qml-tests
      , right?
      Is it possible to provide a minimal example illustrating that qmlEngineAvailable gets called?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Marc_Van_Daele
        wrote on last edited by
        #3

        Adding Q_OBJECT and #include "main.moc" at the end solved this issue

        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