QWarn in qtest does not print anything

  • Probably a trivial error, I just don't know what it is. Searched google, but couldn't find anything relevant (lots of closed bugs though).

    I use Fedora 21, Qt5.4 and Qml 2, and I use QtTest. It all seems to work together fine, but my QWARN never prints anything, neither do I get messages from the Qt system that uses qwarn.

    I tried including <QDebug> to no avail.

    Does anyone know how to get QWARN to work?

  • Lifetime Qt Champion


    Without any code it's pretty much Crystal Ball debugging. Can you share your code ?

  • Hmm, bummer, I smashed my crystal ball ..... xD

    Okee, adding a sample from the code (would be a bit much to show everything, and probably not helpful). The QWARN you see here, compiles, but shows nothing. My suspicion is it is a macro that was commented unless something is defined.

    #include <QtQml>

    #include "testport.h"
    #include "utils.h"

    TestPort::TestPort(QObject *parent) : QObject(parent)





    • @brief TestPort::testPortCreation A simple test for creating a Port.
    • No further test necessary: QML takes care of all
      void TestPort::testPortCreation() {
      QQmlEngine engine;
      QQmlComponent component(&engine, QUrl("qrc:testport_1.qml"));
      model::Port *port = qobject_cast<model::Port *>(component.create());
      if (port) {
      QCOMPARE(port->name(), QString("testport1"));
      QCOMPARE(port->rdy(), QString("rdy1"));
      QCOMPARE(port->compName(), QString("compName1"));
      } else {
      QWARN("Creation of Port not successful. Recheck qml and qrc files.");


  • Lifetime Qt Champion

    Might be a silly question but are you sure that you are passing by the else case ?

  • Yep, completely. I have now added a std::cout << of component.errors() (broken down into strings) and finally got the error message. Still, the QWARN is silent.

Log in to reply

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