Solved Include header issue
-
If it solved then make it solved.
-
I have added main class but the issue is still present.
Test project is available here - Mega.
-
still you made mistake,
you have created communicationWorker object in AppSetting and in communicationWorker you created testWindow object and then in testwindow you created appsetting object, so it again became cycle.
what i suggest you is,
in communicationWorker create both appsetting and testwindow objects,in communicationWorker made connections between appsetting and testwindow
whenever any signal emited in any of these two class catch those on communicationworker class and pass to required class.
what you made in above example that is wrong.
-
OK. Then in what file I should include
communicationWorker.h
? Thanks. -
I don't think you have clear the difference between a class and an instance of the class.
Personally I think that guerilla programming is evil so: http://www.bogotobogo.com/cplusplus/files/c-gui-programming-with-qt-4-2ndedition.pdf
-
class AppSettings
is a class
AppSettings *testSettings = new AppSettings()
- is the instance of the class (heap);
AppSettings testSettings;
- is the instance of the class (stack).But to get the instance of a class you should include the appropriate header file.
So I'm not right? -
I have changed code to your suggestion but it's not emitting a signal.
Test project - Mega.
Can you show an example? Thanks.
-
@Cobra91151
you need to include the header file only when you instantiate an object.in your header file, you only declare pointers, so forward declaration is enough. you only need to include header file in cpp file
and in your code, your main function just have a
TestWindow
, there is neitherCommunicationWorker
norAppSettings
, so the connection betweenTestWindow
andAppSettings
do not exist.I think @Venkatesh-V's suggestion is creating a
CommunicationWorker
as the top object, so you only need to createCommunicationWorker
in the main function.but you can just declare
AppSettings
asTestWindow
's member, and connect them in the constructor ofTestWindow
-
I changed code to yours suggestions but windows are not communicate.
My codes and test project are available - Mega.
Can someone post an example or fix my test project? Thanks in advance.
-
I have fixed it by adding a button as a trigger, so now everything works.