Is there any DatePicker control for Qt 5?

I am writing my first QML / Javascript application for QtQuick 2.0. I need to set a DatePicker element, but I did not find such a control under QtQuick.Controls - and nowhere else, in fact -.

I'm starting to believe that there is no way to name the "native" DatePicker in QML. Should I implement one or is there one?

+8
datepicker qml qtquick2
source share
3 answers

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

Datepicker example

He intends to use this way:

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

It is assumed that you are using it from a Window object, and it needs a parent link to show the datupixer in the correct position (it shows the calendar in a new window).

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

This is the first version and it takes a lot of Polish to be ready, but it is the starting point.

+7
source share

Just in case anyone stumbles upon this, there is a Calendar element in QtQuick.Controls. This should facilitate the implementation of such a Datepicker : http://qt-project.org/doc/qt-5/qml-qtquick-controls-calendar.html

+7
source share

** Code for DatePicker. Try it ** **

 *TextField { id: textDate x: 10 y: 42 width: 175 height: 33 placeholderText: qsTr("Text Field") text:Qt.formatDate(cal.selectedDate, "dd-MM-yyyy") font.bold: true font.family:"times new roman" font.pointSize: 12 } Button { id: button x: 198 y: 42 width: 25 height: 29 Image { x: -4 y: -4 id: img width: 36 height: 44 source: "/Images/calendar-512.png" } onClicked:{ cal.visible=true } } Calendar{ id:cal x: 10 y: 82 width: 220 height: 205 visible: false selectedDate: new Date() onClicked: { textDate.text=Qt.formatDate(cal.selectedDate, "dd-MM-yyyy"); cal.visible=false } }* 
0
source share

All Articles