Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

main.cpp Example File
ipc/cannonserver/main.cpp

    /****************************************************************************
    **
    ** This file is part of the Qt Extended Opensource Package.
    **
    ** Copyright (C) 2009 Trolltech ASA.
    **
    ** $QT_EXTENDED_DUAL_LICENSE$
    **
    ****************************************************************************/

    #include <QtopiaApplication>
    #include <QDebug>
    #include <QtopiaIpcAdaptor>
    #include <QString>
    #include <QtGlobal>
    #include <cstdlib>

    class CannonListener : public QtopiaIpcAdaptor
    {
        Q_OBJECT

    public:
        CannonListener(QObject *parent = 0);

    public slots:
        void shootCannon(int);

    signals:
        void missed();
        void hit();
    };

    CannonListener::CannonListener(QObject *parent)
        : QtopiaIpcAdaptor("QPE/CannonExample", parent)
    {
        publishAll(QtopiaIpcAdaptor::SignalsAndSlots);
    }

    void CannonListener::shootCannon(int power)
    {
        int pwr = power % 100;
        int roll = qrand() % 100;

        if (pwr >= roll)
            emit hit();
        else
            emit missed();

        deleteLater();
    }

    int main( int argc, char **argv)
    {
        QtopiaApplication app(argc, argv);

        CannonListener *listener = new CannonListener;
        app.registerRunningTask("CannonListener", listener);

        app.exec();
    }

    #include "main.moc"


Copyright © 2009 Trolltech Trademarks
Qt Extended 4.4.3