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. QML ProgressBar Qt 5.7 has no style and color property

QML ProgressBar Qt 5.7 has no style and color property

Scheduled Pinned Locked Moved Solved QML and Qt Quick
9 Posts 3 Posters 7.9k 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.
  • G Offline
    G Offline
    Galbarad
    wrote on 20 Nov 2016, 18:34 last edited by Galbarad
    #1

    Hi to all
    I have problem with ProgressBar component

    import QtQuick.Controls 2.0
    
    ProgressBar {
            id: pbLife
            value: 0.5
            color: "red" // run time error 
            style:  ProgressBarStyle {}  // run time error 
            height: iLifeIcon.height
            anchors.right: parent.right
            anchors.left: iLifeIcon.right
            anchors.verticalCenter: iLifeIcon.verticalCenter
        }
    
    C J 2 Replies Last reply 20 Nov 2016, 20:07
    0
    • G Galbarad
      20 Nov 2016, 18:34

      Hi to all
      I have problem with ProgressBar component

      import QtQuick.Controls 2.0
      
      ProgressBar {
              id: pbLife
              value: 0.5
              color: "red" // run time error 
              style:  ProgressBarStyle {}  // run time error 
              height: iLifeIcon.height
              anchors.right: parent.right
              anchors.left: iLifeIcon.right
              anchors.verticalCenter: iLifeIcon.verticalCenter
          }
      
      C Offline
      C Offline
      CharlieG
      wrote on 20 Nov 2016, 20:07 last edited by
      #2

      Hi, @Galbarad,

      Unless I am mistaken, QtQuick.Controls 2.0 are not style proporty. But you can use background property inherited from Control

      Hope this helps

      G 1 Reply Last reply 24 Nov 2016, 15:08
      2
      • G Galbarad
        20 Nov 2016, 18:34

        Hi to all
        I have problem with ProgressBar component

        import QtQuick.Controls 2.0
        
        ProgressBar {
                id: pbLife
                value: 0.5
                color: "red" // run time error 
                style:  ProgressBarStyle {}  // run time error 
                height: iLifeIcon.height
                anchors.right: parent.right
                anchors.left: iLifeIcon.right
                anchors.verticalCenter: iLifeIcon.verticalCenter
            }
        
        J Offline
        J Offline
        Julien B
        wrote on 22 Nov 2016, 15:14 last edited by
        #3

        Hello @Galbarad ,

        You have an example in the documentation Customizing ProgressBar.

        1 Reply Last reply
        3
        • C CharlieG
          20 Nov 2016, 20:07

          Hi, @Galbarad,

          Unless I am mistaken, QtQuick.Controls 2.0 are not style proporty. But you can use background property inherited from Control

          Hope this helps

          G Offline
          G Offline
          Galbarad
          wrote on 24 Nov 2016, 15:08 last edited by
          #4

          Hi @CharlieG,
          yes style property not available in 2.0 but according documentation property "color" should be available, but it's not available too
          hm can't found doc with "color", but see that "style" still in doc
          http://doc.qt.io/qt-5/qml-qtquick-controls-progressbar.html#style-prop

          @Julien-B thanks I'll check

          J 1 Reply Last reply 24 Nov 2016, 15:26
          0
          • G Galbarad
            24 Nov 2016, 15:08

            Hi @CharlieG,
            yes style property not available in 2.0 but according documentation property "color" should be available, but it's not available too
            hm can't found doc with "color", but see that "style" still in doc
            http://doc.qt.io/qt-5/qml-qtquick-controls-progressbar.html#style-prop

            @Julien-B thanks I'll check

            J Offline
            J Offline
            Julien B
            wrote on 24 Nov 2016, 15:26 last edited by Julien B
            #5

            @Galbarad ,

            The link you provided is for Quick Controls 1.4. but in List of All Members for ProgressBar (1.4) there is style but not color.

            The proper links for Quick Controls 2.0 are ProgressBar QML Type (2.0) and List of All Members for ProgressBar (2.0) and neither color nor style appears in it.

            1 Reply Last reply
            1
            • G Offline
              G Offline
              Galbarad
              wrote on 24 Nov 2016, 19:26 last edited by
              #6

              @Julien-B thanks for proper documentation
              yep my fault, looks like I see color property in other place ((
              thank for help

              1 Reply Last reply
              0
              • G Offline
                G Offline
                Galbarad
                wrote on 29 Nov 2016, 13:14 last edited by
                #7

                Hi all
                I found that example from documentation Customizing ProgressBar has problem in case ProgressBar located in other place than left top corner
                please check working example

                import QtQuick 2.6
                import QtQuick.Controls 2.0
                
                Rectangle {
                    width: 400
                    height: 600
                
                    ProgressBar {
                        id: control
                        value: 0.5
                        padding: 2
                
                        width: 100
                        height: 8
                        z: 100
                
                        anchors.centerIn: parent
                
                        background: Rectangle {
                            anchors.left: control.left
                            anchors.verticalCenter: control.verticalCenter
                            implicitWidth: 50
                            implicitHeight: 6
                            color: "#e6e6e6"
                            radius: 3
                        }
                
                        contentItem: Rectangle {
                            anchors.left: control.left
                            anchors.verticalCenter: control.verticalCenter
                            width: control.visualPosition * control.width
                            height: control.height
                            radius: 2
                            color: "#17a81a"
                            z:101
                        }
                    }
                }
                
                J 1 Reply Last reply 30 Nov 2016, 07:59
                0
                • G Galbarad
                  29 Nov 2016, 13:14

                  Hi all
                  I found that example from documentation Customizing ProgressBar has problem in case ProgressBar located in other place than left top corner
                  please check working example

                  import QtQuick 2.6
                  import QtQuick.Controls 2.0
                  
                  Rectangle {
                      width: 400
                      height: 600
                  
                      ProgressBar {
                          id: control
                          value: 0.5
                          padding: 2
                  
                          width: 100
                          height: 8
                          z: 100
                  
                          anchors.centerIn: parent
                  
                          background: Rectangle {
                              anchors.left: control.left
                              anchors.verticalCenter: control.verticalCenter
                              implicitWidth: 50
                              implicitHeight: 6
                              color: "#e6e6e6"
                              radius: 3
                          }
                  
                          contentItem: Rectangle {
                              anchors.left: control.left
                              anchors.verticalCenter: control.verticalCenter
                              width: control.visualPosition * control.width
                              height: control.height
                              radius: 2
                              color: "#17a81a"
                              z:101
                          }
                      }
                  }
                  
                  J Offline
                  J Offline
                  Julien B
                  wrote on 30 Nov 2016, 07:59 last edited by Julien B
                  #8

                  @Galbarad ,

                  It looks like a bug but I cannot confirm, I checked with console.log and it seems contentItem Rectangle width is overriden when you use anchors.centerIn: parent in your ProgressBar, even if control.visualPosition * control.width provide the right result and I don't know why.

                  Anyway you can try this temporary workaround (tested on linux).

                  Replace in ProgressBar

                  anchors.centerIn: parent
                  

                  by

                  x: parent.width/2 - control.width/2
                  y: parent.height/2 - control.height/2
                  
                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    Galbarad
                    wrote on 30 Nov 2016, 15:44 last edited by
                    #9

                    Hi @Julien-B
                    I try workaround, but with no success, may I ask your full test file?

                    I found another problem when I use ProgressBar with background and contentItem I get qml runtime error
                    qrc:///qml/GameField.qml: Object destroyed during incubation

                    ProgressBar {
                                id: pbLife
                                value: 0.5
                    
                                height: 0.8 * iLifeIcon.height
                                anchors.right: parent.right
                                anchors.left: iLifeIcon.right
                                anchors.verticalCenter: iLifeIcon.verticalCenter
                    
                                background: Rectangle {
                                    anchors.fill: pbLife
                                    color: "transparent"
                                    radius: 3
                                    border.color: "#000000"
                                    border.width: 1
                                }
                    
                                contentItem: Rectangle {
                                    anchors.left: pbLife.left
                                    anchors.verticalCenter: pbLife.verticalCenter
                                    width: pbLife.visualPosition * pbLife.width
                                    height: pbLife.height
                                    radius: 2
                                    color: "#FF0000"
                                    //z: 10
                                }
                            }
                    
                    1 Reply Last reply
                    0

                    9/9

                    30 Nov 2016, 15:44

                    • Login

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