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. elide not working
Forum Updated to NodeBB v4.3 + New Features

elide not working

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 1.4k 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.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by
    #1

    Here I have a simple rectangle which will contain a string entered by the user. If the string does not fit within the width of the rectangle I would like to show the ellipse. However, elide is not working like I thought it would, is there something I have missed?

                Rectangle {
                    id: display
                    color: "white"
                    height: componentHeight
                    width: componentWidth
                    radius: 5
    
                    TextStyled {
                        id: textEntryDisplay
                        elide: Text.ElideRight
                        style: fontStyle
                        anchors.horizontalCenter: parent.horizontalCenter
                        anchors.bottom: display.bottom
                        color: modelData.settingInvalid ? "red" : "gray"
                        Component.onCompleted: {
                            if(modelData.settingInvalid)
                            {
                                textEntryDisplay.text = modelData.value
                                value_container.allowNext = false
                            } else
                            {
                                textEntryDisplay.text = modelData.value
                            }
                        }
                    }
                }
    

    Here is TextStyled.qml:

    Text {
        id: control
    
        property BaseTextStyle style: Style1TextStyle {}
    
        font: control.style.font
        color: control.style.color
    }
    
    Pablo J. RoginaP 1 Reply Last reply
    0
    • C Circuits

      Here I have a simple rectangle which will contain a string entered by the user. If the string does not fit within the width of the rectangle I would like to show the ellipse. However, elide is not working like I thought it would, is there something I have missed?

                  Rectangle {
                      id: display
                      color: "white"
                      height: componentHeight
                      width: componentWidth
                      radius: 5
      
                      TextStyled {
                          id: textEntryDisplay
                          elide: Text.ElideRight
                          style: fontStyle
                          anchors.horizontalCenter: parent.horizontalCenter
                          anchors.bottom: display.bottom
                          color: modelData.settingInvalid ? "red" : "gray"
                          Component.onCompleted: {
                              if(modelData.settingInvalid)
                              {
                                  textEntryDisplay.text = modelData.value
                                  value_container.allowNext = false
                              } else
                              {
                                  textEntryDisplay.text = modelData.value
                              }
                          }
                      }
                  }
      

      Here is TextStyled.qml:

      Text {
          id: control
      
          property BaseTextStyle style: Style1TextStyle {}
      
          font: control.style.font
          color: control.style.color
      }
      
      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @circuits said in elide not working:

      However, elide is not working like I thought it would,

      Please provide some output showing what happening...

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • C Offline
        C Offline
        Circuits
        wrote on last edited by
        #3

        Sure no problem:

        0_1568398921128_problems.png

        1 Reply Last reply
        0
        • IntruderExcluderI Offline
          IntruderExcluderI Offline
          IntruderExcluder
          wrote on last edited by IntruderExcluder
          #4

          This is because your Text element doesn't have width property

          C 1 Reply Last reply
          2
          • IntruderExcluderI IntruderExcluder

            This is because your Text element doesn't have width property

            C Offline
            C Offline
            Circuits
            wrote on last edited by
            #5

            @intruderexcluder WOW! I swear to god I tried that... I am a fool, thank you!

            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