Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QML Button Text disappears while scrolling the listview.

QML Button Text disappears while scrolling the listview.

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 830 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.
  • M Offline
    M Offline
    mantra
    wrote on last edited by
    #1

    Hi, Whenever I am scrolling my listview with Buttons inside it, sometimes the button text disappears, How can i fix this?

    ODБOïO 1 Reply Last reply
    0
    • M mantra

      Hi, Whenever I am scrolling my listview with Buttons inside it, sometimes the button text disappears, How can i fix this?

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      @mantra hi
      Giving your OS, qt version, compiler and code snippet that shows the issue may help

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mantra
        wrote on last edited by
        #3

        Yep sure,
        OS: Windows 10
        Qt Version: Qt Creator 4.10.1 - Based on Qt 5.13.1 (MSVC 2017, 32 bit)
        Compiler: I am using mingw64
        Code Snippet:

                      Grid {
                                        id: gridID
                                        anchors.bottom: componentAbove.bottom
                                        anchors.left: componentAbove.left
                                        anchors.leftMargin: componentAbove.iLeftMargin
                                        anchors.bottomMargin: 23
                                        width: parentComponent.width
                                        spacing: 15
                                        columns: 3
        
                                        Repeater {
                                            id:buttonsRepeater
                                            model: buttonList
        
                                            Button {
                                                height: 72
                                                property string strBtnColor: "white"
                                                property string strBtnFontColor: "black"
                                                text: "modelText"
                                                background: Rectangle {
                                                    radius: 16
                                                    border.color: "black"
                                                    border.width: 2
                                                    color: strButtonColor
                                                }
                                                leftPadding: 40
                                                rightPadding: 40
                                                font.pixelSize: 36
                                                font.styleName:strFontRegular
                                                font.bold: false
                                                property int clickDuration: 70
                                                onClicked: {
                                                        strBtnFontColor = "white"
                                                        strBtnColor = "green"
                                                        clickTimer.start();
                                                    }
                                                }
        
                                                Timer {
                                                    id:  clickTimer
                                                    interval: parent.clickDuration
                                                    running: false
                                                    repeat: false
                                                    onTriggered: {
                                                        clickTimer.stop();
                                                        strBtnColor = "white"
                                                        strBtnFontColor = "black"
                                                    }
                                                }
                                            }
                                        }
                                    }
        

        This is inside ListView , so i have dynamic buttons w.r.t my model but when i am scrolling my list, buttons text dissappear!

        ODБOïO 1 Reply Last reply
        0
        • M mantra

          Yep sure,
          OS: Windows 10
          Qt Version: Qt Creator 4.10.1 - Based on Qt 5.13.1 (MSVC 2017, 32 bit)
          Compiler: I am using mingw64
          Code Snippet:

                        Grid {
                                          id: gridID
                                          anchors.bottom: componentAbove.bottom
                                          anchors.left: componentAbove.left
                                          anchors.leftMargin: componentAbove.iLeftMargin
                                          anchors.bottomMargin: 23
                                          width: parentComponent.width
                                          spacing: 15
                                          columns: 3
          
                                          Repeater {
                                              id:buttonsRepeater
                                              model: buttonList
          
                                              Button {
                                                  height: 72
                                                  property string strBtnColor: "white"
                                                  property string strBtnFontColor: "black"
                                                  text: "modelText"
                                                  background: Rectangle {
                                                      radius: 16
                                                      border.color: "black"
                                                      border.width: 2
                                                      color: strButtonColor
                                                  }
                                                  leftPadding: 40
                                                  rightPadding: 40
                                                  font.pixelSize: 36
                                                  font.styleName:strFontRegular
                                                  font.bold: false
                                                  property int clickDuration: 70
                                                  onClicked: {
                                                          strBtnFontColor = "white"
                                                          strBtnColor = "green"
                                                          clickTimer.start();
                                                      }
                                                  }
          
                                                  Timer {
                                                      id:  clickTimer
                                                      interval: parent.clickDuration
                                                      running: false
                                                      repeat: false
                                                      onTriggered: {
                                                          clickTimer.stop();
                                                          strBtnColor = "white"
                                                          strBtnFontColor = "black"
                                                      }
                                                  }
                                              }
                                          }
                                      }
          

          This is inside ListView , so i have dynamic buttons w.r.t my model but when i am scrolling my list, buttons text dissappear!

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @mantra said in QML Button Text disappears while scrolling the listview.:

          This is inside ListView

          What do you mean by that ? Is this code used as your Listview Delegate ?

          Please try to provide a runnable code and show how it is used in a listview ?

          Also you can use the highlighted property with a ColorAnimation or States instead of the Timer to change the aspect of the button after a click

          M 1 Reply Last reply
          1
          • ODБOïO ODБOï

            @mantra said in QML Button Text disappears while scrolling the listview.:

            This is inside ListView

            What do you mean by that ? Is this code used as your Listview Delegate ?

            Please try to provide a runnable code and show how it is used in a listview ?

            Also you can use the highlighted property with a ColorAnimation or States instead of the Timer to change the aspect of the button after a click

            M Offline
            M Offline
            mantra
            wrote on last edited by
            #5

            @LeLev I tried using States as well, I am still facing the same issue, whenever I am scrolling the text inside the buttons disappear, and once i click over any button I get the text back, but i want button text to be there all the time.

            ODБOïO 1 Reply Last reply
            0
            • M mantra

              @LeLev I tried using States as well, I am still facing the same issue, whenever I am scrolling the text inside the buttons disappear, and once i click over any button I get the text back, but i want button text to be there all the time.

              ODБOïO Offline
              ODБOïO Offline
              ODБOï
              wrote on last edited by
              #6

              @mantra hi you did not answer my 2 questions

              @LeLev said in QML Button Text disappears while scrolling the listview.:

              What do you mean by that ? Is this code used as your Listview Delegate ?
              Please try to provide a runnable code and show how it is used in a listview ?

              M 1 Reply Last reply
              1
              • ODБOïO ODБOï

                @mantra hi you did not answer my 2 questions

                @LeLev said in QML Button Text disappears while scrolling the listview.:

                What do you mean by that ? Is this code used as your Listview Delegate ?
                Please try to provide a runnable code and show how it is used in a listview ?

                M Offline
                M Offline
                mantra
                wrote on last edited by mantra
                #7

                Hey @LeLev , Thank you being a help, I didn't answer your 2 questions coz i felt issue is not related to any of them, I tried setting one property and it got resolved.

                clip: true
                

                If there was something in code, I know you could have resolved it. Thanks.

                1 Reply Last reply
                1

                • Login

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