Search code examples
quickdialog

How can I set the mode of a QDateTimeElement using json?


I'm using QuickDialog to generate forms from JSON, all is well, other than the date/time picker. Unfortunately, the documentation does mention the different types of date pickers available. The sample source also produces forms from code, however I want to produce it using the JSON mechanism.

Here is an extract of my JSON. This only chooses the time only picker:

"elements": [
    {"type":"QDateTimeInlineElement","title":"Date"}, // time only picker
    {"type":"QDateTimeInlineElement","mode":"UIDatePickerModeDate","title":"Date"}, // crashes
    {"type":"QDateTimeElement","title":"Date","date":"01/03/2013"}, // crashes
    {"type":"QDateTimeInlineElement","title":"Date","mode":"1"}, // crashes
    {"type":"QDateTimeInlineElement","title":"Time"} // time only
]

Solution

  • Turns out I was close with the mode. This is what ended up giving me the date only when the form was built using json only:

    {"type":"QDateTimeInlineElement","title":"Date","_mode":"1"}, //works
    

    This works because the 1 is what the UIDatePickerModeDate value of UIDatePickerMode enum evaluates to.