You should use Component as the property type:
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
Rectangle {
property Component 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"
}
}
ProgressBar {
id: progressBar
NumberAnimation {
target: progressBar
property: "value"
to: 1
running: true
duration: 2000
}
style: progressBarErrorStyle
}
}
The components for styles are used in Loader
items internally, which create instances of the components when they need to, just like delegates in Qt Quick's ListView, for example.