main.cpp Example File
ipc/cannonclient/main.cpp
#include <QtopiaApplication>
#include <QDebug>
#include <QtopiaIpcAdaptor>
#include <QString>
class CannonResultListener : public QObject
{
Q_OBJECT
public:
CannonResultListener(QObject *parent = 0);
public slots:
void missed();
void hit();
};
CannonResultListener::CannonResultListener(QObject *parent)
: QObject(parent)
{
}
void CannonResultListener::missed()
{
qDebug() << "Cannon missed.";
deleteLater();
}
void CannonResultListener::hit()
{
qDebug() << "Cannon HIT!!!";
deleteLater();
}
int main( int argc, char **argv)
{
QtopiaApplication app(argc, argv);
if (argc != 2) {
qDebug() << "Please specify the cannonPower argument";
return 0;
}
CannonResultListener *listener = new CannonResultListener;
QtopiaIpcAdaptor *adaptor = new QtopiaIpcAdaptor("QPE/CannonExample");
QtopiaIpcAdaptor::connect(adaptor, MESSAGE(missed()), listener, SLOT(missed()));
QtopiaIpcAdaptor::connect(adaptor, MESSAGE(hit()), listener, SLOT(hit()));
app.registerRunningTask("CannonResultListener", listener);
adaptor->send(MESSAGE(shootCannon(int)), QString(argv[1]).toInt());
app.exec();
delete adaptor;
}
#include "main.moc"
Copyright © 2009 Trolltech |
Trademarks |
Qt Extended 4.4.3 |