
Originally Posted by
nupul
I have this Design issue with my Qt app.
The two modules were created independently, and thus two "main.cpp" files. This helped us test the working independently.
Now what I am not able to figure out is this:
Without using aggregation (i.e. declaring MyInterface objects in Controller) how do I activate the signals/slots,
s.t. when a button is clicked in Module 1, the Corresponding interface designed in module 2 should be invoked.
ummm I am quite
I'll appreciate your help
Thanks
Nupul
Connect the two objects together in a single main, e.g:
// Create objects
Controller* c = new Controller(...);
MyInterface* mi = new MyInterface(...);
...
// Connect objects together
QObject::connect(c
->button1,
SIGNAL(clicked
()), mi,
SLOT(handleButton1Click
()));
QObject::connect(c
->button2,
SIGNAL(clicked
()), mi,
SLOT(handleButton2Click
()));
...etc.
// Create objects
Controller* c = new Controller(...);
MyInterface* mi = new MyInterface(...);
...
// Connect objects together
QObject::connect(c->button1, SIGNAL(clicked()), mi, SLOT(handleButton1Click()));
QObject::connect(c->button2, SIGNAL(clicked()), mi, SLOT(handleButton2Click()));
...etc.
To copy to clipboard, switch view to plain text mode
Personally I would make the buttons private members of Controller and capture and re-emit their signals from controller, but that's outside the scope of this problem.
Bookmarks