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. dynamic Text in Rectangle
Forum Updated to NodeBB v4.3 + New Features

dynamic Text in Rectangle

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 411 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.
  • R Offline
    R Offline
    RobyS
    wrote on last edited by
    #1

    Goodmorning,
    i need to create dynamic text and change it in runtime...i can do this without problems, but now i need to have a text with background color!
    normally i use a text in rectangle and i create it dynamically as:

    Rectangle {

    color: "#808080"
    Text {
        font.pixelSize: 50;
    }
    width: childrenRect.width
    height: childrenRect.height
    

    }

    when i refer to this i have a rectangle object back, but i can't to handle Text!!

    J.HilkJ 1 Reply Last reply
    0
    • R RobyS

      Goodmorning,
      i need to create dynamic text and change it in runtime...i can do this without problems, but now i need to have a text with background color!
      normally i use a text in rectangle and i create it dynamically as:

      Rectangle {

      color: "#808080"
      Text {
          font.pixelSize: 50;
      }
      width: childrenRect.width
      height: childrenRect.height
      

      }

      when i refer to this i have a rectangle object back, but i can't to handle Text!!

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @RobyS said in dynamic Text in Rectangle:

      when i refer to this i have a rectangle object back, but i can't to handle Text!!

      I interpret this as you want to access the text property, but from the outside you only see the properties of the rectangle ?

      Rectangle {
      
      property alias text: textId.text
      color: "#808080"
      Text {
          id:textId
          font.pixelSize: 50;
      }
      width: childrenRect.width
      height: childrenRect.height
      }
      
      
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RobyS
        wrote on last edited by
        #3

        yes, i need to change text, i know is not possible to refer it by ID

        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