Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Use Style for QtQuick.Controls from Resources file

$
0
0
Hey, I want to use al the components and stuff in my QT/QML application from the Resources file. Everything worked but i have a am not able load the style of a QtQuick.Control Item from Recources Here my Style File: (ButtonStylePercentage.qml) import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.2 import QtGraphicalEffects 1.0   ButtonStyle {     label: Component {                     Text {                         text: control.text                         clip: true                         wrapMode: Text.WordWrap                         verticalAlignment: Text.AlignVCenter                         horizontalAlignment: Text.AlignHCenter                         anchors.fill: parent                         font.pixelSize: 18                         font.bold: true                         color: control.hovered ? "#026cce" : "#000000"                     }                 }         background: Item{             Item {                 id: backgroundButton2                 implicitWidth: control.width                 implicitHeight: control.height                   visible: false                   Rectangle {                     id:buttBack2                     implicitWidth: control.width-2                     implicitHeight: control.height-2                     anchors.centerIn: backgroundButton2                       border.width: control.activeFocus ? 2 : 1                     border.color: "#888"                     radius: 100                     gradient: Gradient {                         GradientStop { position: 0 ; color: control.pressed ? "#313131" : "#9f9f9f" }                         GradientStop { position: 1 ; color: control.pressed ? "#4b4b4b" : "#afafaf" }                     }                 }             }                 InnerShadow{                     source:backgroundButton2                     anchors.fill: backgroundButton2                       radius: 5                     samples: 32                       color: "#E0000000"                       spread: 0.15                 }         }     } and here its usage without Resouces File: This works fine     Button {         id:button50             text: "50 %"             x:100             y:25+titleBlock.height             width: 100             height: 50               onClicked: {                 contSlider.value = 50             }             style: ButtonStylePercentage {}     } now i tried to use it from Recourcesfile like this     Button {         id:button50             text: "50 %"             x:100             y:25+titleBlock.height             width: 100             height: 50               onClicked: {                 contSlider.value = 50             }             style: "qrc:///qmlFiles/qml/Komponenten/ButtonStylePercentage.qml"     } This throws error when executing: qrc:///qmlFiles/qml/Komponenten/ContControl.qml:113:20: Invalid property assignment: unsupported type “QQmlComponent*” How could this Problem be solved? Thanks! Greets Nico

Viewing all articles
Browse latest Browse all 4972

Trending Articles