Home > OS >  Qt6.3 QML Calendar Error Composite Singleton Type Calendar is not creatable
Qt6.3 QML Calendar Error Composite Singleton Type Calendar is not creatable

Time:06-02

I try to use Calendar like doc.

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    Calendar{
        minimumDate: new Date(2017, 0, 1)
        maximumDate: new Date(2018, 0, 1)
    }
}

But I got this error: Composite Singleton Type Calendar is not creatable. Any one knows how to use it?

CodePudding user response:

you're probably confusing Calendar (a widget) from Qt5 with Calendar (a namespace) from Qt 6.

In Qt 6 that works a bit different, you have to create this control by yourself, for example:

ColumnLayout {
    DayOfWeekRow {
        locale: grid.locale
        Layout.fillWidth: true
    }

    MonthGrid {
        id: grid
        month: Calendar.December // this is how the Calendar can be used
        year: 2022
        locale: Qt.locale("en_US")
        Layout.fillWidth: true
    }
}
  • Related