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. Is there a way we can use a period/dot seperator in variable names in qml for setting property/context property
Forum Updated to NodeBB v4.3 + New Features

Is there a way we can use a period/dot seperator in variable names in qml for setting property/context property

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 683 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
    gautam
    wrote on last edited by
    #1

    My QML file should look something like this

    @Rectangle {
    id: rect
    width: 500
    height: 500
    color: "#654321"
    Text {
    text: Group1.SetA.myText
    anchors.centerIn: parent
    }
    }
    @

    Somewhere in my C code I would like to do something like below to update the text
    RootContext->setContextProperty("Group1.SetA.myText", "ValueString");
    OR
    myViewer->setProperty("Group1.SetA.myText", "ValueString");

    Is that possible ? Can we use period/dot in qml property names? If not, is there any other way ?

    1 Reply Last reply
    0
    • X Offline
      X Offline
      Xander84
      wrote on last edited by
      #2

      I don't think you can do that, but there are many ways to set the value.
      You could use a global property and bind it to the text and then easily change it from c++ or you get the specific QML item from c++ which is not that easy I think. Depending on how often you need to do that the quick (and maybe dirty) way is to use the evaluate function of the QML engine, there you can run any valid QML code like Javascript evil function, just from c++.

      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