1
2 File myapp.cpp
3 -------------------------------
4 #include <kapp.h>
5 #include <dcopclient.h>
6
7 int main(int nargs, char** argv) {
8 KApplication* a = new KApplication(nargs, argv, "myapp");
9 a->setMainWidget(new ASmartWidget("smart"));
10 QByteArray data, reply_data; // a byte array for the data and for the reply
11 QCString reply_type; // will contain the type of the reply
12
13 client = a.dcopClient();
14 client.attach();
15 client.registerAs("myapp");
16
17 if (!client->call("otherClientId", // identify the recipient
18 "anObject/aChildOject", // designate the targeted object
19 "readAnIntAndAnswer(int)", // method to handle data and answer
20 data, // sent data
21 reply_type, // type of data contained in the answer
22 reply_data); // the answer
23 kdDebug << "Calling over DCOP failed!" << endl;
24 else {
25 if (reply_type == "Qstring") {
26 this->doSomething(answer(reply_data, IO_ReadOnly));
27 } else
28 kdDebug << "Calling over DCOP succeeded,\
29 but the answer had wrong type!" << endl;
30 }
31
|