//![0]
int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml"));
    QObject *item = view.rootObject();

    MyClass myClass;
    QObject::connect(item, SIGNAL(qmlSignal(QString)),
                     &myClass, SLOT(cppSlot(QString)));

    view.show();
    return app.exec();
}
示例#2
0
文件: main.cpp 项目: ftena/qml-c
int main(int argc, char *argv[])
{
     QGuiApplication app(argc, argv);

     QQmlApplicationEngine engine;
     engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
     QObject *item = engine.rootObjects().first();

     MyClass myClass;
     QObject::connect(item, SIGNAL(qmlSignal(QString)),
                      &myClass, SLOT(cppSlot(QString)));

     return app.exec();
}
示例#3
0
int main(int argc, char *argv[])
   {
   QApplication app(argc, argv);

   QQmlApplicationEngine engine;
   engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

   QObject* root = engine.rootObjects()[0];

   SignalHandler *signalHandler = new SignalHandler(root);

   QObject::connect(root, SIGNAL(qmlSignal(QString)),
   signalHandler, SLOT(cppSlot(QString)));

   return app.exec();
   }
示例#4
0
int main(int argc, char *argv[])
{
   QGuiApplication app(argc, argv);

  QQuickView view(QUrl("qrc:main.qml"));
  view.setResizeMode(QQuickView::SizeRootObjectToView);

  QQmlContext *ctxt = view.rootContext();

  TicTacEngine dataObject;
  ctxt->setContextProperty("_myClass", &dataObject);

   QObject *button = view.rootObject();

   QObject::connect(button, SIGNAL(qmlSignal(QVariant)),
                       &dataObject, SLOT(reset(QVariant)));

  view.show();

  return app.exec();
}
示例#5
0
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
    QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));
    QScopedPointer<QQuickView> viewPage2(Sailfish::createView("pages/SecondPage.qml"));
    //------------------

    //Label do ktorego sa wrzucane komunikaty z serwera (tekstowe)
    LabelClass * lblC = new LabelClass();
    //Label odpowiedzialny za obsługe zegara
    LabelClock * lblClock = new LabelClock();
    //Zbior labeli odpowiedzialny za zmiane stanu etykiet informacyjnych
    LabelSet  * lblSet = new LabelSet();


    //Powiazanie obiektow LabelClass i LabelClock z elementami interfejsu
    view->rootContext()->setContextProperty("LabelClass",lblC);
    view->rootContext()->setContextProperty("LabelClock",lblClock);

    //----------------------
    //Powiazanie obiektow etykiet z elementami interfejsu.
     QObject * lblLoud = view->rootObject()->findChild<QObject*>("lblLoud");
     lblSet->lblLoud = lblLoud;
     QObject * lblQuit = view->rootObject()->findChild<QObject*>("lblQuit");
     lblSet->lblQuit = lblQuit;
     QObject * lblFast = view->rootObject()->findChild<QObject*>("lblFast");
     lblSet->lblFast = lblFast;
     QObject * lblSlow = view->rootObject()->findChild<QObject*>("lblSlow");
     lblSet ->lblSlow = lblSlow;
     QObject * lblNext = view->rootObject()->findChild<QObject*>("lblNext");
     lblSet ->lblNext = lblNext;
    //----------------------
    //Utworzenie obiektu serwera
    Server * s = new Server(0,lblC,lblSet);
    //nasluchiwanie serwera
    s->listen();
    //--------------------

    //Oniekt klasy Common zawierajacej metody
    Common common;

    lblClock->setbtnName("Rozpocznij prezentację");
    lblClock->settime("0:0:0");

    //--------------------

    //Wyszukanie Page z main.qml.
    QObject *itemPage = view->rootObject()->findChild<QObject*>("pol3");

    //----------------------
    //Powiazanie sygnalow ze slotami
    QObject::connect(itemPage, SIGNAL(qmlSignalTimerChange(QString)),lblClock, SLOT(timerSet(QString)));
    QObject::connect(itemPage, SIGNAL(qmlSignal(QString)),&common, SLOT(cppSlot(QString)));
    QObject::connect(itemPage, SIGNAL(qmlSignal(QString)), &common,SLOT(cppDisconect(QString)));
    QObject::connect(itemPage, SIGNAL(qmlSignalStartClock()),lblClock, SLOT(timerStop()));

    //----------------------

    Sailfish::showView(view.data());


    return app->exec();
}