Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to Pass values from C++ to QML in a QT widget application
Forum Updated to NodeBB v4.3 + New Features

How to Pass values from C++ to QML in a QT widget application

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 176 Views 2 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.
  • J Offline
    J Offline
    Jaswenth S
    wrote on last edited by
    #1

    I am beginner to Qt , I am facing issue on transmitting value from C++ to QML,
    I am able to get the value from QT UI but I can't able to emit that ,
    And in QML i am getting error called
    ReferenceError: <class given in setContextProperty > is not defined
    I was stuck here , help me in this

    1 Reply Last reply
    0
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by mrdebug
      #2
      .h
      signals:
          void attendanceSet(QString Stirng01);
      
      .cpp
              this->rootContext()->setContextProperty("MyClass", this);
              this->load(QUrl(QStringLiteral("qrc:///Qml/main.qml")));
      
      .ccp (in a timer)
      emit attendanceSet("Hello");
      
      .qml
          Connections {
              target: MyClass
              onAttendanceSet: attendanceSet(Stirng01);
          }
      
          function attendanceSet(Stirng01) {
              console.log(Stirng01)
          }
      

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      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