Qt 5.2 cannot get qWait function to work

2.4k Views Asked by At

I've got a header file with the following include:

#include <QtTest/QtTest>

I am trying to use the following line to generate a non-blocking wait in my main window:

QTest::qWait(1000 - ui->speedDial->value());

I receive the following error:

mainwindow.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl QTest::qSleep(int)" (__imp_?qSleep@QTest@@YAXH@Z) referenced in function "void __cdecl QTest::qWait(int)" (?qWait@QTest@@YAXH@Z)

Can anyone help me understand what I am doing wrong, or provide an alternative method? These lines are independent of other code.

1

There are 1 best solutions below

0
On BEST ANSWER

It works fine for me. Check this example which is a modified version of the Qt Test official documentation example:

tutorial1.pro:

SOURCES = testqstring.cpp
CONFIG  += qtestlib

# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial1
sources.files = $$SOURCES *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial1
INSTALLS += target sources

symbian {
    TARGET.UID3 = 0xA000C60B
    include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

symbian: warning(This example might not fully work on Symbian platform)
maemo5: warning(This example might not fully work on Maemo platform)
simulator: warning(This example might not fully work on Simulator platform)

testqstring.cpp:

#include <QtTest/QtTest>
#include <QDebug>

class TestQString: public QObject
{
    Q_OBJECT
private slots:
    void toUpper();
};

void TestQString::toUpper()
{
    QString str = "Hello";

    QTest::qWait(2000);

    QCOMPARE(str.toUpper(), QString("HELLO"));
}

QTEST_MAIN(TestQString)
#include "testqstring.moc"