Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Have truble with binding

    C++ Gurus
    2
    4
    1108
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      Germ last edited by

      Hi community!
      I have some truble with binding.
      I whant to create a very simple programm for example, just for me. This program will show text wich i input in textbox 1 in textbox 2. I use pattern MVVM.
      My exaple : http://rghost.ru/52524855
      Thanks for help.

      1 Reply Last reply Reply Quote 0
      • JKSH
        JKSH Moderators last edited by

        Hi, and welcome to the Qt Dev Net!

        Can you please post your code directly in the forum? Just add '@' before and after the code, and it will be formatted nicely. That will make it easier for everyone to read. :)

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply Reply Quote 0
        • G
          Germ last edited by

          Yes, of course.
          My main:
          @ #include <qmlapplicationviewer.h>
          #include <QApplication>
          #include <QGuiApplication>
          #include <QQmlEngine>
          #include <qdeclarativecontext.h>
          //#include <qqmlcontext>
          #include <qqml.h>
          #include <QtQuick/qquickitem.h>
          #include <QtQuick/qquickview.h>
          #include "MainModel.h"
          #include "MainViewModel.h"

          int main(int argc, char *argv[])
          {
          QApplication app (argc, argv); //
          // QmlApplicationViewer viewer;
          // viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
          QmlApplicationViewer viewer;

          MainModel mainModel; //
          

          // viewer.rootContext()->setContextProperty("model", new MainViewModel(mainModel));
          // viewer.setMainQmlFile(QLatin1String("Button.qml"));
          // viewer.showExpanded();

           QDeclarativeContext *ctxt = viewer.rootContext();
           ctxt->setContextProperty("myModel", QVariant::fromValue(mainModel));
          
          // viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
          // viewer.setMainQmlFile&#40;QLatin1String("Button.qml"&#41;&#41;;
          // viewer.showExpanded();
          
          
          
          
          
          QDeclarativeView *view = new  QDeclarativeView; //
          view->setSource(QUrl::fromLocalFile&#40;"Button.qml"&#41;&#41;; //
          

          // //view->rootContext()->setContextProperty("model", new MainViewModel(mainModel));
          view->show(); //

           return app.exec&#40;&#41;;
          

          }
          @

          Sorry for comments in code.

          1 Reply Last reply Reply Quote 0
          • JKSH
            JKSH Moderators last edited by

            What do you mean by "problem with binding"? Please explain in more detail.

            By the way, you should use classes that start with "QQml" or "QQuick". "QDeclarative is old and deprecated. See http://qt-project.org/doc/qt-5/qtquick-porting-qt5.html#c-code

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply Reply Quote 0
            • First post
              Last post