Unsolved Style into button
-
Hello I use version QT 5.14.2 and .. why I cannot use style into component button ??
this error i see : Cannot assign to non-existent property "style"
thanks for your answer.import QtQuick 2.0 import QtQuick.Controls 2.14 import QtQuick.Controls.Styles 1.4 import QtGraphicalEffects 1.0 Button { id: buttonSimple property var colSfondoBtnAlias property var colSfondoGradientBtnAlias property var objNameTabSplitAlias text: "Button" y: 0 x: 0 icon.name: "example" icon.source: "images/white/button_delete.png" icon.color: "#000000" style: ButtonStyle { background: Rectangle { id: rectanglebuttonCloseMenuFilter anchors.fill: parent border.width: control.activeFocus ? 2 : 1 radius: 4 gradient: Gradient { GradientStop { position: 0 ; color: buttonSimple.pressed ? buttonSimple.colSfondoBtn : buttonSimple.colSfondoGradientBtn } GradientStop { position: 1 ; color: buttonSimple.pressed ? "#000000" : buttonSimple.colSfondoBtn } } } } }
-
See here; https://forum.qt.io/topic/79071/how-to-set-style-of-button-in-qml
Try this;
import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.12 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Button { id: control text: "Button" anchors.centerIn: parent background: Rectangle { implicitWidth: 200 implicitHeight: 50 border.width: control.activeFocus ? 2 : 1 border.color: "#888" radius: 4 gradient: Gradient { GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" } GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" } } } } }