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. Update a text object in Qml from C++
Forum Updated to NodeBB v4.3 + New Features

Update a text object in Qml from C++

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qtquick
3 Posts 2 Posters 966 Views
  • 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.
  • C Offline
    C Offline
    coldspark29
    wrote on 29 Aug 2021, 09:40 last edited by
    #1

    I have a very basic main.qml file that I want to update from the main.cpp file. The qml file looks like this

    Window {
            width: 1920
            height: 1080
            visible: true
            color: "#000000"
            visibility: Window.FullScreen
        
            Text {
                id: example_text
                x: 82
                y: 322
                color: "#ffffff"
                text: qsTr("text_to_edit")
                font.pixelSize: 64
                font.family: "IBM Plex Mono"
            }
    }
    

    I found this post which involves a second qml file as component, which I have tried, but I can't create the objectName attribute. Can I somehow reference this by the id?

    https://forum.qt.io/topic/74151/updating-qml-gui-from-c/6

    E 1 Reply Last reply 29 Aug 2021, 09:43
    0
    • C coldspark29
      29 Aug 2021, 09:40

      I have a very basic main.qml file that I want to update from the main.cpp file. The qml file looks like this

      Window {
              width: 1920
              height: 1080
              visible: true
              color: "#000000"
              visibility: Window.FullScreen
          
              Text {
                  id: example_text
                  x: 82
                  y: 322
                  color: "#ffffff"
                  text: qsTr("text_to_edit")
                  font.pixelSize: 64
                  font.family: "IBM Plex Mono"
              }
      }
      

      I found this post which involves a second qml file as component, which I have tried, but I can't create the objectName attribute. Can I somehow reference this by the id?

      https://forum.qt.io/topic/74151/updating-qml-gui-from-c/6

      E Offline
      E Offline
      eyllanesc
      wrote on 29 Aug 2021, 09:43 last edited by
      #2

      @coldspark29 See https://stackoverflow.com/questions/60646345/proper-way-to-update-qml-object-from-c/60646426#60646426

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        coldspark29
        wrote on 29 Aug 2021, 10:09 last edited by
        #3

        Thanks, I just wanted to clarify my question, because I thought it was lacking details. With the help of the provided post, I managed to create an updater thread to update my values. :)

        1 Reply Last reply
        0

        1/3

        29 Aug 2021, 09:40

        • Login

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