PDA

View Full Version : Signal/Slots across different files--help needed



swamyonline
30th June 2008, 19:48
hi ppl,
this issue might be addressed before, but i did not find right solution. in my application i am using one file(ex..mainwindow.cpp) for gui drawing and some other files for accessing and controlling gui. if the signals r generated in mainwindow.cpp (gui file) they should be accessed in the control files and vice versa.. how can i do that. guys, pls help in this regard. iam giving the outline of my application.

// 1. main.cpp
#include "mainwindow.h"
main
{
create mainwindow object and show. // its the gui window
}

// 2. mainwindow.cpp
#include "mainwindow.h"
{
create gui window and display.
setup signals for window widgets and their corresponding slots.
}

// 3. controller1.cpp
{
catch signals from mainwindow.cpp and do some controller activities.
emit signals for mainwindow.cpp and to be used to perform gui activities.
}

i might not explain the outline properly, but the idea is to access signals and slots of one file(rather class) from other file(class) and vice versa..
pls put some light on to this topic and suggest me solutions..thank u.

MrShahi
1st July 2008, 05:34
whtever I understood, you should use an object of that class into different class to access its signal .....
you can also use flag to emit signal on that particuler event.....

swamyonline
1st July 2008, 20:30
thanks shahi,
i got the solution from one article on net.. what ever u suggested was the same thing that i tried. thank u very much for ur reply..by the way, QSharedMemory is available only from Qt 4.4 onwards? i think sharedmemory is the best way to share data among objects..

jacek
2nd July 2008, 02:39
by the way, QSharedMemory is available only from Qt 4.4 onwards?
Yes.


i think sharedmemory is the best way to share data among objects..
Shared memory is an inter-process communication mechanism. You don't need it to pass data between objects whithin a single process. It would be like using a corkboard in the hall to talk to a friend that sits besides you.