diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-12-02 18:54:14 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-12-11 13:12:31 +0100 |
commit | 3e9895f3de7f118beab3068b938ff6b9f2f5ef73 (patch) | |
tree | 2143f8987db7942e63325edf650c26a7c2b16913 /src/gui/painting/qregion.cpp | |
parent | 5a26bf9d65b75db3abefa967beb13b2510719bd5 (diff) |
Support checkable QComboBox items with styles using a popup dropdown
The dropdown of a combobox is rendered using menu items when the style
request it to do so via the SH_ComboBox_Popup style hint.
In that case, checkable items were not supported; the QComboBox didn't
pass the checked state correctly to the style, and the delegate used
for rendering the items into the list view did not implement modifying
the checked state of the item.
However, the QStyleOptionMenuItem's checked state and checkType members
were set anyway, as on e.g. macOS style we use a checkmark to show
which item is currently selected in the combobox.
The QStyle::State enum defines State_On and State_Off for toggleable
things, so in addition to setting QStyleOptionMenuItem::checked, we are
now also adding State_On or State_Off if the model provides a valid
checked/unchecked state. Otherwise, we only set the checked state if
the item is currently selected.
In addition, we implement the delegate to support toggling of checkable
model data with mouse and keyboard, using a simplified version of the
QItemDelegate implementation. To avoid spurious item toggles when the
popup is opened, we only handle mouse releases when the press was on
the same row.
In the fusion style, we ignore the workaround to let QtQuickControls
render comboboxes if State_On or State_Off are set.
[ChangeLog][QtWidgets][QComboBox] Support checkable items in styles
that use a popup for the dropdown.
Change-Id: Ia01519694b0419d777dc66b1ef683482fb01754c
Fixes: QTBUG-60310
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'src/gui/painting/qregion.cpp')
0 files changed, 0 insertions, 0 deletions