'font.family' veya 'anchors.fill' gibi iç içe geçmiş özellikler yapmaya çalışıyorum, ancak bunları normal olmayan şekilde başlatamıyorum çünkü 'varolmayan özelliğe atanamıyor' yazdırıyor. Bunun yerine Component.onCompleted yöntemini kullanmak zorunda kaldım. Sorun nedir?Gruplu/iç içe geçmiş özellikler nasıl oluşturulur?
MyButtonStyling.qml:
import QtQml 2.1
QtObject
{
property QtObject background: QtObject
{
property color pressed: "#CCCCCC"
property color enabled: "#666666"
property color disabled: "#555555"
}
}
main.qml:
import QtQuick 2.0
Item
{
width: 400
height: 300
MyButton
{
text: "TEST"
styling: MyButtonStyling
{
//background.enabled: "#1B2E0A" //Cannot assign to non-existent property "enabled"
Component.onCompleted:
{
background.enabled = "#1B2E0A" //Works
}
}
}
}
MyButton.qml:
import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
Button
{
property QtObject styling: MyButtonStyling {}
implicitWidth: 80
implicitHeight: 80
style: ButtonStyle
{
background: Item
{
Rectangle
{
anchors.fill: parent
color: control.pressed ? styling.background.pressed : control.enabled ? styling.background.enabled : styling.background.disabled
}
}
}
}
Eğer yukarıdaki kod ile gerçekleştirmek niyetinde şeyin tam olarak açıklık getirebilir? Bunu başarmanın daha iyi bir yolu olabilir, ama yapmaya çalıştığınız şey konusunda tamamen açık değilim. – MrEricSir