Skip to content

Singleton support #27

@machinekoder

Description

@machinekoder

Not sure if this belongs here or to the qmlweb project.

Singletons are an important design pattern for QML applications. They are most important for creating global style and configuration variables.

A workaround is to use global properties (referencing an item the parent context) e.g.

MyItem.qml

Item {
    color: style.blue1
}

MainWindow.qml

Item {

    QtObject {
        id: style
        readonly property color blue1: "#0000DD"
    }

    MyItem {
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions