main.cpp 887 B

1234567891011121314151617181920212223242526
  1. #include <QtGui/QApplication>
  2. #include <QtDeclarative>
  3. #include <QtDeclarative/QDeclarativeView>
  4. #include <QtDeclarative/QDeclarativeEngine>
  5. #include "mainwidget.h"
  6. #include "cardboard.h"
  7. #include "colortools.h"
  8. Q_DECL_EXPORT int main(int argc, char *argv[])
  9. {
  10. QApplication app(argc, argv);
  11. qmlRegisterType<CardBoard>("ecards.qmlcomponents", 1, 0, "CardTools");
  12. qmlRegisterType<ColorTools>("ecards.qmlcomponents", 1, 0, "ColorTools");
  13. QDeclarativeView qmlview;
  14. qmlview.setSource(QUrl("qrc:/qml/main.qml"));
  15. qmlview.setAttribute(Qt::WA_LockLandscapeOrientation);
  16. ColorTools *colorTools = new ColorTools();
  17. qmlview.rootContext()->setContextProperty("colorTools", colorTools);
  18. CardBoard *cardTools = new CardBoard(&qmlview);
  19. qmlview.rootContext()->setContextProperty("cardTools", cardTools);
  20. qmlview.showFullScreen();
  21. return app.exec();
  22. }