PDA

View Full Version : Can a signal connect to a slot which in other file?



brantyou
14th September 2010, 16:18
Hello!I am a new.In my program,I got a problem.I have a slot in one *.cpp file,and a signal in another *.cpp file.How can I use this signal to connect to that slot?If it can be done.I hope you can give a example code.Thanks very much.

tbscope
14th September 2010, 16:25
Connections are done between objects.

If you have class A in file a.cpp and class B in file b.cpp:


A *a = new A;
B *b = new B;

connect(a, SIGNAL(...), b, SLOT(...));

brantyou
15th September 2010, 00:54
Thanks for your help very much ! I do that. You are right! Because your help,I have known something that unknown before.:D