Search code examples
datepickerqmlqtquick2

Is there any DatePicker control for Qt 5?


I'm writing my first QML/Javascript app for QtQuick 2.0. I need to place a DatePicker control, but I haven't found any control like that under QtQuick.Controls -and nowhere, in fact-.

I'm starting to believe there is no way to call a 'native' DatePicker in QML. Do I have to implement one or there is exist one?


Solution

  • Well, I had to make my own control. It is called Datepicker.

    Datepicker example

    It is intented to used in this way:

    import QtQuick.Controls 1.1
    
    ApplicationWindow {
        id: main
    
        Datepicker {
            id: myDate
            activeWindow: main
            width: 200
        }
    }
    

    It asumes you are using it from a Window object, and needs the parent reference to show the datepicker in the correct position (it shows a calendar in a new window).

    You can download the source code from: https://bitbucket.org/camolin3/datepicker

    This is the first version and need a lot of polish to be ready, but is a start point.