import QtQuick 2.12 import QtQuick.Controls 2.12 Row { property var date id: body // Component.onCompleted: { // // workaround: set model dynamically to enable dragging. Or currentIndex won't be changed properly // year.model=[ // 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, // 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038 // ] // month.model=[ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] // hour.model=[ // '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', // '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', // '20', '21', '22', '23' // ] // minute.model=[ // '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', // '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', // '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', // '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', // '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', // '50', '51', '52', '53', '54', '55', '56', '57', '58', '59' // ] // second.model=[ // '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', // '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', // '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', // '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', // '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', // '50', '51', '52', '53', '54', '55', '56', '57', '58', '59' // ] // } Tumbler { id: year width: 30 height: parent.height model: [ 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038 ] onCurrentIndexChanged: { setDay(); date=timestamp(); console.log('year.currentIndex changed'); } } Tumbler { id: month width: 30 height: parent.height model: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] onCurrentIndexChanged: { setDay(); date=timestamp(); console.log('month.currentIndex changed'); } } Tumbler { id: day width: 30 height: parent.height onCurrentIndexChanged: date=timestamp() } Tumbler { id: hour width: 30 height: parent.height model: [ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23' ] onCurrentIndexChanged: { date=timestamp(); console.log('hour.currentIndex changed'); } } Tumbler { id: minute width: 30 height: parent.height model: [ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59' ] onCurrentIndexChanged: { date=timestamp(); console.log('minute.currentIndex changed'); } } Tumbler { id: second width: 30 height: parent.height model: [ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59' ] onCurrentIndexChanged: { date=timestamp(); console.log('second.currentIndex changed'); } } function setDay() { // backup current index for day let dayLastIndex=day.currentIndex // reset day.model if(month.currentIndex==0 || month.currentIndex==2 || month.currentIndex==4 || month.currentIndex==6 || month.currentIndex==7 || month.currentIndex==9 || month.currentIndex==11) day.model=[ '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'] else if(month.currentIndex==3 || month.currentIndex==5 || month.currentIndex==8 || month.currentIndex==10) day.model=[ '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'] else { // month==February let currentYear=year.model[year.currentIndex] if(currentYear%4==0) { if(currentYear%100==0) day.model=[ '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28'] else day.model=[ '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29'] } else day.model=[ '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28'] } // restore index for day if(dayLastIndex