QT : get the class name of an object
Try using the metaobject. pWin->metaObject()->className();
Try using the metaobject. pWin->metaObject()->className();
You can use the findChild() function with the object name to get a specific child. You can also use findChildren() to get all the children that have the same name and then iterate through the list using foreach() or QListIterator. To get a button you can try: QPushButton* button = pWin->findChild<QPushButton*>(“Button name”);
First structure source like below: MyApp MyAppUnitTest Under MyApp project, use a MyAppSrc.pri to locate source files: SOURCES += \ ../../../framework/src/myapp.cpp \ ../../../framework/src/mycontrol.cpp HEADERS += \ ../../../framework/inc/myapp.h \ ../../../framework/inc/mycontrol.h INCLUDEPATH += ../../../framework/extlibs Include this .pri in MyApp.pro like: include(MyAppSrc.pri) Then structure the testing project exactly like the main project, with one extra include in MyAppUnitTest.pro: … Read more
You don’t have to create separate tests applications. Just use qExec in an independent main() function similar to this one: int main(int argc, char *argv[]) { TestClass1 test1; QTest::qExec(&test1, argc, argv); TestClass2 test2; QTest::qExec(&test2, argc, argv); // … return 0; } This will execute all test methods in each class in one batch. Your testclass … Read more