Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Have truble with binding
Forum Updated to NodeBB v4.3 + New Features

Have truble with binding

Scheduled Pinned Locked Moved C++ Gurus
4 Posts 2 Posters 1.5k Views 1 Watching
  • 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 Offline
    G Offline
    Germ
    wrote on last edited by
    #1

    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
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      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
      0
      • G Offline
        G Offline
        Germ
        wrote on last edited by
        #3

        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
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved