main.cpp Example File
publish-subscribe/main.cpp
#include "publisherdialog.h"
#include "subscriberdialog.h"
#include <QApplication>
#include <qvaluespace.h>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setOrganizationDomain("qt.nokia.com");
app.setApplicationName("Publish Subscribe Example");
bool createDefault = true;
bool createPublisher = false;
bool createSubscriber = false;
for (int i = 1; i < argc; ++i) {
if (argv[i] == QLatin1String("-server")) {
QValueSpace::initValueSpaceServer();
} else if (argv[i] == QLatin1String("-publisher")) {
createPublisher = true;
createDefault = false;
} else if (argv[i] == QLatin1String("-subscriber")) {
createSubscriber = true;
createDefault = false;
}
}
PublisherDialog *publisher = 0;
if (createDefault || createPublisher) {
publisher = new PublisherDialog;
#if defined(MEEGO_EDITION_HARMATTAN)
publisher->show();
#endif
}
SubscriberDialog *subscriber = 0;
if (createDefault || createSubscriber) {
subscriber = new SubscriberDialog;
#if defined(MEEGO_EDITION_HARMATTAN)
subscriber->show();
#elif defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
subscriber->showMaximized();
#endif
}
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
QObject::connect(publisher, SIGNAL(switchRequested()), subscriber, SLOT(showMaximized()));
QObject::connect(publisher, SIGNAL(switchRequested()), subscriber, SLOT(repaint()));
QObject::connect(publisher, SIGNAL(switchRequested()), publisher, SLOT(hide()));
QObject::connect(subscriber, SIGNAL(switchRequested()), publisher, SLOT(showMaximized()));
QObject::connect(subscriber, SIGNAL(switchRequested()), publisher, SLOT(repaint()));
QObject::connect(subscriber, SIGNAL(switchRequested()), subscriber, SLOT(hide()));
#elif defined(MEEGO_EDITION_HARMATTAN)
QObject::connect(publisher, SIGNAL(closeApp()), &app, SLOT(quit()));
QObject::connect(subscriber, SIGNAL(closeApp()), &app, SLOT(quit()));
#endif
int result = app.exec();
if (publisher)
delete publisher;
if (subscriber)
delete subscriber;
return result;
}
[+] Documentation Feedback