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. [SOLVED] ProgressBarStyle in a styling Singleton
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] ProgressBarStyle in a styling Singleton

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 1 Posters 1.2k 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.
  • T Offline
    T Offline
    tmurison
    wrote on last edited by
    #1

    Hi,

    I've been trying various ways to switch out the style of a ProgressBar to indicate an error state. I've tried setting the style in a PropertyChanges, both created there or referenced by id, I've tried using Bindings as well as Loaders and Bindings and finally now a style singleton. I like the Singleton approach best, but I cannot make it work either. Here's my Singleton's code:

    @pragma Singleton
    import QtQuick 2.2
    import QtQuick.Controls 1.1
    import QtQuick.Controls.Styles 1.1

    QtObject {
    property ProgressBarStyle progressBarErrorStyle: ProgressBarStyle {
    background: Rectangle {
    radius: 2
    color: "lightgray"
    border.color: "gray"
    border.width: 1
    implicitWidth: 200
    implicitHeight: 20
    }
    progress: Rectangle {
    color: "orangered"
    border.color: "red"
    }
    }
    }@

    The problem is, when I use progressBarErrorStyle in any of my QML files, its type is ProgressBarStyle_QMLTYPE_17.

    I've asked a couple of questions on Stackoverflow related to what I'm trying to do, so I figured I'd try here...

    http://stackoverflow.com/questions/23210427/cannot-create-certain-qml-types-in-a-singleton
    http://stackoverflow.com/questions/23121106/qml-property-is-null

    What am I missing, is it even possible to swap out a ProgressBar's style at runtime?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tmurison
      wrote on last edited by
      #2

      The solution was to add a qmldir file with:

      @singleton Style Style.qml@

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tmurison
        wrote on last edited by
        #3

        The solution was to add a qmldir file with:

        @singleton Style Style.qml@

        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