[Qt-components] Proposed CheckBox API change

Bache-Wiig Jens Jens.Bache-Wiig at digia.com
Tue Jan 29 11:27:10 CET 2013


> 
> In the few case where you actually make use of the partiallyCheckedState, I would prefer to see all the valid states listed explicitly like this:
> 
> onCheckedStateChanged: {
>     switch (checkedState) :
>        case Qt.Unchecked:
>        case Qt.PartiallyChecked:
>        case Qt.Checked:
>      ... 
> }
> 
> It might be more a bit more verbose but it looks more readable to me. I would also argue that the checked property is effectively undefined while in the partiallyCheckedState as the user can not even tell if the checkBox is checked or unChecked and the state literally means that the checked state is invalid. 


Correcting myself here. The overly complex behaviour described in the first draft is redundant. I would say that the checked state is only ever true if (checkedState === Qt.CheckedState). That is fairly obvious behaviour and it simplifies everything:

/*!
   This property indicates the current checked state of the checkbox.

    Possible values:
    Qt.UnChecked - The checkbox is not checked (default)
    Qt.Checked - The checkbox is checked
    Qt.PartiallyChecked - The checkbox is in a partially checked (or mixed) state
*/
property enum checkedState


/*!
   This property determines whether the \c Qt.PartiallyChecked state is
   available.

   A checkbox may be in a partially checked state when the regular checked
   state can not be determined.
*/
property bool partiallyCheckedEnabled


/*!
   This property determines if the value of \l checkedState is Qt.Checked.
*/
property bool checked

No need for overly complex descriptions. If you need to retain the value before entering the partiallyChecked state you are free todo so yourself and there is no guesswork required as to what the value of properties might be and no undefined behavior.


Regards,
Jens








More information about the Qt-components mailing list