1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #include <QtGui/QApplication>
- #include <QDeclarativeContext>
- #include "qmlapplicationviewer.h"
- #include "filterproxymodel.h"
- #include "purchasableitembase.h"
- #include <QFile>
- #include <QTextStream>
- void myMessageHandler(QtMsgType type, const char *msg)
- {
- QString txt;
- switch (type) {
- case QtDebugMsg:
- txt = QString("Debug: %1").arg(msg);
- break;
- case QtWarningMsg:
- txt = QString("Warning: %1").arg(msg);
- break;
- case QtCriticalMsg:
- txt = QString("Critical: %1").arg(msg);
- break;
- case QtFatalMsg:
- txt = QString("Fatal: %1").arg(msg);
- abort();
- }
- QFile outFile("c:/data/TryAndBuy.log");
- outFile.open(QIODevice::WriteOnly | QIODevice::Append);
- QTextStream ts(&outFile);
- ts << txt << endl;
- }
- int main(int argc, char *argv[])
- {
- QApplication app(argc, argv);
- //qInstallMsgHandler(myMessageHandler);
- QmlApplicationViewer viewer;
- viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
- //connecting model to QML
- FilterProxyModel model;
- viewer.rootContext()->setContextProperty("catalogModel", &model);
- //create filters and connect them to QML
- ItemsToBuyModel itemsToBuyModel(*model.sourceModel());
- viewer.rootContext()->setContextProperty("itemsToBuyModel", &itemsToBuyModel);
- ItemsYouHaveModel itemsBoughtModel(*model.sourceModel());
- viewer.rootContext()->setContextProperty("itemsBoughtModel", &itemsBoughtModel);
- viewer.setMainQmlFile(QLatin1String("qml/main.qml"));
- viewer.showExpanded();
- return app.exec();
- }
|