Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Access Material Theme Properties in a .ui.qml file



  • Hello,

    I have a QtQuick UI Form that has a designer editable .ui.qml using the Material Theme

    Page {
        width: 1700
        height: 750
        property alias busyIndicator1: busyIndicator1
            BusyIndicator {
                id: busyIndicator1
                x: 391
                y: 391
            }
    
    }
    

    And i the .qml file I want to change the The Material Accent

    import QtQuick 2.4
    import QtQuick.Controls 2.4
    import QtQuick.Controls.Material 2.4
    
    AutomaticModeForm {
    
      busyIndicator1{
          Material.accent: Material.Red
      }
    }
    

    If I start I get the QML Error qrc:/AutomaticMode.qml:19 Attached properties cannot be used here

    Which is clear as I have to make the Material property accessible.

    I also tried per Hand to add property alias Material: accent to the qml.ui
    but this does not seem to work.

    Page {
        width: 1700
        height: 750
        property alias busyIndicator1: busyIndicator1
        property alias Material: accent
            BusyIndicator {
                id: busyIndicator1
                x: 391
                y: 391
            }
    
    }
    

    What is the correct way to make the Material property accessible?

    Kindest Regards & Big thanks

    Erik


Log in to reply