Solved QTest GUI getting started
-
@jastmc said in QTest GUI getting started:
MyMainWindow_ = new MyMainWindow;
I should have said the error occurs on the line on the line
MyMainWindow_ = new MyMainWindow;
-
[EDIT: please ignore this post, it's irrelevant and wrong. Sorry!]
@jastmc
Since the example you quote uses:mainWindow_ = new MainWindow();
why do you write
MyMainWindow_ = new MyMainWindow;
and then ask why it doesn't behave same?
-
@jastmc said in QTest GUI getting started:
MyMainWindow_ = new MyMainWindow;
undefined reference to `MyMainWindow::MyMainWindow(QWidget)'*.
It says it dont know your constructor.
I would completely delete the build folder, and run qmake + rebuild all.
If error persists, please check that MyMainWindow.cpp is actual included into the .pro file
so it gets linked to the tst_mytest project. -
Hi,
In your test, you only build the test sources itself. What about the class you want to test ?
-
@JNBarchan said in QTest GUI getting started:
@jastmc
Since the example you quote uses:mainWindow_ = new MainWindow();
why do you write
MyMainWindow_ = new MyMainWindow;
and then ask why it doesn't behave same?
Whoops? For my own edification, does stinky C++ allow you to omit the
()
innew Something
and call a default constructor? parameterless constructor? complain if multiple constructors? or what?? -
@SGaist OK. How do I make sure the class to be tested is built first?
Regards
Jas -
@jastmc Add it to SOURCES and HEADERS in your pro file.
-
@JNBarchan
yes the new operator/compiler can construct an object if it can find
a default constructor (ctor). The ctor is a special function and and that is why () can be omitted even one often consider it just a function call. -
@jsulm Thanks, that was part of it.
I then had to add
INCLUDEPATH += $$PWD/../MyApp/ \ ../../build-MySolution-Desktop_Qt_5_7_0_GCC_64bit-Debug/MyApp/ \
to the MyTest.pro file because the next message was that it could not find the ui_mymainwindow.h file. So that solved it.
Regards,
Jas -
You are missing the
FORMS
variable in your .pro file.