Qt Quick based coffee brewing control chart.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include <QtGui>
  2. #include <QtDeclarative>
  3. #include "qmlapplicationviewer.h"
  4. #include "qmllineitem.h"
  5. class QmlWindow : public QMainWindow
  6. {
  7. Q_OBJECT
  8. public:
  9. QmlWindow(QWidget *parent = NULL);
  10. Q_INVOKABLE QAction *addMenuItem(QString menu, QString item);
  11. private:
  12. QHash<QString,QMenu *> menus;
  13. };
  14. QmlWindow::QmlWindow(QWidget *parent) : QMainWindow(parent)
  15. {
  16. }
  17. QAction *QmlWindow::addMenuItem(QString menu, QString item)
  18. {
  19. QMenu *theMenu;
  20. if(menus.contains(menu))
  21. {
  22. theMenu = menus.value(menu);
  23. }
  24. else
  25. {
  26. theMenu = menuBar()->addMenu(menu);
  27. menus.insert(menu, theMenu);
  28. }
  29. return theMenu->addAction(item);
  30. }
  31. QML_DECLARE_TYPE(QmlWindow)
  32. int main(int argc, char *argv[])
  33. {
  34. QApplication app(argc, argv);
  35. qmlRegisterType<QmlLineItem>("CustomComponents", 1, 0, "Line");
  36. qmlRegisterType<QmlWindow>("CustomComponents", 1, 0, "Window");
  37. QmlWindow *window = new QmlWindow(NULL);
  38. window->setWindowTitle("BrewPlot");
  39. QmlApplicationViewer *viewer = new QmlApplicationViewer;
  40. viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
  41. viewer->rootContext()->setContextProperty("window", window);
  42. viewer->setSource(QUrl("qrc:/qml/qml/BrewPlot/main.qml"));
  43. app.connect(viewer->engine(), SIGNAL(quit()), SLOT(quit()));
  44. window->setCentralWidget(viewer);
  45. viewer->setMinimumSize(viewer->sizeHint());
  46. window->show();
  47. return app.exec();
  48. }
  49. #include "moc_main.cpp"