PDA

View Full Version : Accessing slots of other classes



papillon
14th January 2011, 00:22
Sorry if this is a newbie question: I've searched the forum and googled, but could not find any informations about it.
I have a project organized in 3 c++ (plus headers):

- main.cpp
- child1.cpp
- child2.cpp

I was wondering if there is a way, for widgets in child1.cpp, to connect access slots in child2.cpp

Thanks

tbscope
14th January 2011, 06:24
You need to create objects and then connect the objects.
You can not connect classes directly.

example:

MyClass1 objectOfTypeMyClass1;
MyClass2 *pointerToAnObjectOfMyClass2 = new MyClass2;

connect(&objectOfTypeMyClass1, SIGNAL(someSignal()), pointerToAnObjectOfMyClass2, SLOT(someSlot()));