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. onTextChanged Topic
Forum Updated to NodeBB v4.3 + New Features

onTextChanged Topic

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.0k 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.
  • Pradeep KumarP Offline
    Pradeep KumarP Offline
    Pradeep Kumar
    wrote on last edited by
    #1

    hello

    i have a rectangle and text inside a rectangle,
    im making use property, property string typestring= "",
    first it will be null

    then making use of onTextChanged,
    i need to update text inide the rectangle, help me out.

    code is:
    // parent rectangle
    Rectangle {
    id: root
    width: 500
    height: 500

    // making use of property which at first will be null
    property string typestring: ""

    // one more rectangle, child of root
    Rectangle
    {
    id: rect1
    width: 100
    height: 100
    color: "blue"
    // text inside the rect1
    Text {
    id: t1
    color: "black"
    anchors.centerIn: parent
    onTextChanged:
    {

    if(condition)
    {
    typestring == " some text" // has to get printed in text
    }
    else if(condition)
    {
    typestring = "text" // this has to printed in text of rectangle
    }
    }
    }
    }

    but im getting nothing in text,

    if i make use property string typestring = "hello"

    in that case only hello is printed,
    i need with respect to some condition in if else, that string has to get printed in text of rectangle.

    Pradeep Kumar
    Qt,QML Developer

    p3c0P 1 Reply Last reply
    0
    • Pradeep KumarP Pradeep Kumar

      hello

      i have a rectangle and text inside a rectangle,
      im making use property, property string typestring= "",
      first it will be null

      then making use of onTextChanged,
      i need to update text inide the rectangle, help me out.

      code is:
      // parent rectangle
      Rectangle {
      id: root
      width: 500
      height: 500

      // making use of property which at first will be null
      property string typestring: ""

      // one more rectangle, child of root
      Rectangle
      {
      id: rect1
      width: 100
      height: 100
      color: "blue"
      // text inside the rect1
      Text {
      id: t1
      color: "black"
      anchors.centerIn: parent
      onTextChanged:
      {

      if(condition)
      {
      typestring == " some text" // has to get printed in text
      }
      else if(condition)
      {
      typestring = "text" // this has to printed in text of rectangle
      }
      }
      }
      }

      but im getting nothing in text,

      if i make use property string typestring = "hello"

      in that case only hello is printed,
      i need with respect to some condition in if else, that string has to get printed in text of rectangle.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Pradeep-Kumar As said earlier please edit the post and put code markers.

      157

      1 Reply Last reply
      0
      • Pradeep KumarP Offline
        Pradeep KumarP Offline
        Pradeep Kumar
        wrote on last edited by
        #3

        kk i'l do it

        import QtQuick 1.1

        Rectangle {
        property string typestring: ""

        Rectangle
        {
            Text {
                id: t1
                anchors.centerIn: parent
        

        onTextChanged:
        {

        if(condition)
        {
        typestring == " some text" // has to get printed in text
        }
        else if(condition)
        {
        typestring = "text" // this has to printed in text of rectangle
        }
        }
        }
        }
        }

        the information has to appear in Text, based on codition in onTextChanged, please help me.

        Pradeep Kumar
        Qt,QML Developer

        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