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

Re-use Property



  • Hello, everybody,

    I would like to define Probertys like colors, width, height etc. globel and save them in a separate QML file:

    // ProbertyFile.qml
    import QtQuick 2.0
    Item {
    id : probertys
    proberty int aX : 10
    proberty int aY: 12
    proberty int aHeight : 3
    proberty int aWidth : 5
    proberty color aColorBlack : "#000000"
    // etc.
    }

    If I want to access these probertys, they will unfortunately not be used:

    e.g.:
    ...
    color : ProbertyFile.aColorBlack
    ...

    Can someone give me an impression of where my mistake is?

    Thanks for your help, ThommyB



  • @thommyb hi

    One solution is to define a Singleton
    see here Approach 2: Style Singleton

    @thommyb said in Re-use Property:

    Can someone give me an impression of where my mistake is?

    Reading the Approach 1: Custom Component you should understand where the error is.
    Application output tab of QtCreator sould also show the error line/description


Log in to reply