Qt 4.3.2: QSignalSpy -> no such signal ...
-
hallo,
ich bin vllt. mal wieder blind, aber habe das so oft gesehen problem, dass mir gesagt wird "no such signal ...", obwohl keine der bekannten ursachen (Q_OBJECT, qmake ausfuehren usw.) zuzutreffen scheint.
erstmal etwas code:
element.h:
#include <QObject> class Element: public QObject { Q_OBJECT public: // [ ... ] enum errType { INVALID_START_POINT, INVALID_END_POINT, }; public slots: void setStart( const double &p_start ); void setEnd( const double &p_end ); // [ ... ] signals: void error( errType p_err ); // [ ... ] };test.h:
#include <QObject> #include <QtTest> #include <QSignalSpy> #include <QList> #include <QVariant> #include "element.h" class Test : public QObject { Q_OBJECT private slots: void testElement(); };test.cpp:
#include "test.h" void Test::testElement() { Element elem1; QVERIFY( elem1.start() == 0.0 ); QVERIFY( elem1.end() == 1.0 ); //////////// HIER SCHEINT DER FEHLER ZU LIEGEN (??) /////////// QSignalSpy spy1( &elem1, SIGNAL( error( Element::errType ) ) ); elem1.setStart( 4.2 ); elem1.setEnd( 13.37 ); QVERIFY( spy1.count() == 2 ); spy1.clear(); elem1.setStart( 42.0 ); elem1.setEnd( 1.337 ); QVERIFY( spy1.count() == 2 ); QList< QVariant > args1 = spy1.at( 0 ); QList< QVariant > args2 = spy1.at( 1 ); QVERIFY( args1.at( 0 ).canConvert< Element::errType >() == true ); QVERIFY( args1.at( 0 ) == Element::INVALID_START_POINT ); QVERIFY( args1.at( 1 ).canConvert< Element::errType >() == true ); QVERIFY( args1.at( 1 ) == Element::INVALID_END_POINT ); } QTEST_MAIN( Test )zuletzt noch das pro-file fuers testen (testIt.pro):
TARGET = bin/testIt TEMPLATE = app CONFIG += qtestlib HEADERS += src/element.h src/elements.h src/test.h SOURCES += src/element.cpp src/elements.cpp src/test.cpp OBJECTS_DIR = tmp UI_DIR = tmp MOC_DIR = tmp RCC_DIR = tmpfuehre ich nun
qmake testIt.pro && make && bin/testItaus, bekomme ich ausgegeben
********* Start testing of Test ********* Config: Using QTest library 4.3.2, Qt 4.3.2 PASS : Test::initTestCase() QWARN : Test::testElement() QSignalSpy: No such signal: 'error(Element::errType)' FAIL! : Test::testElement() 'spy1.count() == 2' returned FALSE. () Loc: [src/test.cpp(12)] PASS : ::cleanupTestCase() Totals: 2 passed, 1 failed, 0 skipped ********* Finished testing of Test ********* bash-3.2$wie gesagt, das problem scheint beim QSignalSpy oder in der Element-klasse zu liegen, ich weiss aber nicht genau, wo.
ich hoffe, mir kann jemand bezueglich des "no such signal ..." helfen.
danke schon einmal im Voraus!
mfg,
julian
-
hi,
die loesung gabs im Qt-forum: http://qtforum.de/forum/viewtopic.php?t=6673&highlight=
mfg,
julian