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. Unable to style my progressbar
Forum Updated to NodeBB v4.3 + New Features

Unable to style my progressbar

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

    Hello everyone, I am struggling with my QML code. I want to style my progress bar (it display free space on disk) so that the lower "value" is, the more red the color will be. I am using example code from documentation. But QT creator display error "Invalid property name "style".

    I am using QT 5.15.15 and writing QML code inside .ui.qml so I can display it in main.qml with StackView.

    import QtQuick 2.15
    import QtQuick.Controls 2.15
    import QtQuick.Controls.Styles 1.4
    import QtQuick.Layouts 1.15
    
    ...
                Row {
                    spacing: 10
                    TextEdit {
                        text: progressBar.value.toFixed(2)
                        selectByMouse: true
                        font.bold: true
                    }
                    ProgressBar {
                        id: progressBar
                        objectName: "stats_dis_space_low"
                        value: 0
                        from: 0
                        to: 100
                        style: ProgressBarStyle {
                            background: Rectangle {
                                radius: 2
                                color: "lightgray"
                                border.color: "gray"
                                border.width: 1
                                implicitWidth: 200
                                implicitHeight: 24
                            }
                            progress: Rectangle {
                                color: "lightsteelblue"
                                border.color: "steelblue"
                            }
                        }
                    }
                }
    ...
    

    I guess the problem might be that "style" is no longer supported, but I have no idea how to circumvent it without overriding the whole ProgressBar.

    Any tips are welcome, thank you!

    B 1 Reply Last reply
    0
    • T TMarek

      Hello everyone, I am struggling with my QML code. I want to style my progress bar (it display free space on disk) so that the lower "value" is, the more red the color will be. I am using example code from documentation. But QT creator display error "Invalid property name "style".

      I am using QT 5.15.15 and writing QML code inside .ui.qml so I can display it in main.qml with StackView.

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Controls.Styles 1.4
      import QtQuick.Layouts 1.15
      
      ...
                  Row {
                      spacing: 10
                      TextEdit {
                          text: progressBar.value.toFixed(2)
                          selectByMouse: true
                          font.bold: true
                      }
                      ProgressBar {
                          id: progressBar
                          objectName: "stats_dis_space_low"
                          value: 0
                          from: 0
                          to: 100
                          style: ProgressBarStyle {
                              background: Rectangle {
                                  radius: 2
                                  color: "lightgray"
                                  border.color: "gray"
                                  border.width: 1
                                  implicitWidth: 200
                                  implicitHeight: 24
                              }
                              progress: Rectangle {
                                  color: "lightsteelblue"
                                  border.color: "steelblue"
                              }
                          }
                      }
                  }
      ...
      

      I guess the problem might be that "style" is no longer supported, but I have no idea how to circumvent it without overriding the whole ProgressBar.

      Any tips are welcome, thank you!

      B Offline
      B Offline
      Bob64
      wrote on last edited by
      #2

      @TMarek I think you are mixing Qt Quick Controls with code suitable for Qt Quick Controls 1. The latter is deprecated in Qt 5 .15 and has been removed completely from Qt 6.

      There is a customisation guide here that is the correct one to follow: https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-progressbar

      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