Question

I am trying to create a "Qt unit test" following this tutorial. I created a new project: Qt Gui Application with a header file as mentioned and a class that contains the test function. I added #CONFIG += testlib to my ".pro" file. However, when I run my code, I get this errors:

In function `simulateEvent':

  • error: undefined reference to `_imp___ZN5QTest15defaultKeyDelayEv'
  • error: undefined reference to `_imp___ZN5QTest15defaultKeyDelayEv'
  • error: undefined reference to `_imp___ZN5QTest5qWarnEPKcS1_i'

then in function 'mouseEvent':

  • error: undefined reference to `_imp___ZN5QTest17defaultMouseDelayEv'
  • error: undefined reference to `_imp___ZN5QTest17defaultMouseDelayEv'
  • error: undefined reference to `_imp___ZN5QTest17defaultMouseDelayEv'
  • error: undefined reference to `_imp___ZN5QTest17defaultMouseDelayEv'
  • error: undefined reference to `_imp___ZN5QTest5qWarnEPKcS1_i'

then in function 'simulateEvent' again:

  • error: undefined reference to `_imp___ZN5QTest15defaultKeyDelayEv'
  • error: undefined reference to `_imp___ZN5QTest15defaultKeyDelayEv'
  • error: undefined reference to `_imp___ZN5QTest5qWarnEPKcS1_i'

then in function 'mouseEvent' again:

  • error: undefined reference to `_imp___ZN5QTest17defaultMouseDelayEv'
  • error: undefined reference to `_imp___ZN5QTest17defaultMouseDelayEv'
  • error: undefined reference to `_imp___ZN5QTest17defaultMouseDelayEv'
  • error: undefined reference to `_imp___ZN5QTest17defaultMouseDelayEv'
  • error: undefined reference to `_imp___ZN5QTest5qWarnEPKcS1_i'

I could not find any explanation for this as everything looks right . what am I missing ?

Was it helpful?

Solution

Try QT += testlib, without starting #

OTHER TIPS

Try Qt += declarative, testlib didn't work for me, but declarative did.

I had the same problem. In my case: I used "delete" on an instance of a class what was inherited from QWidget. I had to change the inheritance for my class from QWidget to QObject.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top