Go to file
Volker Hilsheimer 3e9895f3de 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>
2019-12-11 13:12:31 +01:00
bin Merge remote-tracking branch 'origin/5.13' into 5.14 2019-11-13 07:21:33 +01:00
config.tests Merge remote-tracking branch 'origin/5.14' into 5.15 2019-10-16 01:00:49 +02:00
dist Add changes file for Qt 5.13.2 2019-10-24 13:59:27 +02:00
doc Doc: Move the common documentation to a qdocinc 2019-11-18 12:34:32 +01:00
examples Merge remote-tracking branch 'origin/5.14' into 5.15 2019-12-10 13:51:40 +02:00
lib Purge all fonts 2015-08-18 19:59:14 +00:00
mkspecs Merge remote-tracking branch 'origin/5.14' into 5.15 2019-12-10 13:51:40 +02:00
qmake Merge remote-tracking branch 'origin/5.14' into 5.15 2019-12-10 13:51:40 +02:00
src Support checkable QComboBox items with styles using a popup dropdown 2019-12-11 13:12:31 +01:00
tests MIME: Make the internal database direct content, not a Qt resource 2019-12-10 15:56:09 -08:00
util Unicode tables: minor prettification 2019-11-28 11:04:39 +01:00
.gitattributes Update the git-archive export options 2012-09-07 15:39:31 +02:00
.gitignore qfloat16: Check in the tables to Git 2019-06-03 10:42:53 -07:00
.qmake.conf Bump version 2019-10-14 09:44:06 +02:00
.tag Update the git-archive export options 2012-09-07 15:39:31 +02:00
config_help.txt configure: Add sanitizer "fuzzer-no-link" 2019-11-14 15:45:02 +01:00
configure Android: remove remaining reference to -android-toolchain-version 2019-11-18 14:13:32 +01:00
configure.bat Configure: simplify logic 2019-03-14 12:13:58 +00:00
configure.json configure: Add sanitizer "fuzzer-no-link" 2019-11-14 15:45:02 +01:00
configure.pri Merge remote-tracking branch 'origin/5.14' into 5.15 2019-11-15 16:29:40 +01:00
header.BSD Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.COMM Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.FDL Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.GPL Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.GPL-EXCEPT Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.LGPL Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.LGPL3 Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.LGPL3-COMM Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.LGPL-NOGPL2 Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.LGPL-ONLY Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.MIT qsimd: add support for new x86 CPU features 2018-05-05 06:20:07 +00:00
INSTALL INSTALL: Remove outdated reference to Windows CE 2019-02-13 13:01:57 +00:00
LICENSE.FDL Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
LICENSE.GPL2 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3-EXCEPT Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.LGPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.LGPLv3 Remove LICENSE.GPLv3, LICENSE.LGPLv21, LGPL_EXCEPTION.txt 2018-04-16 11:02:14 +00:00
LICENSE.QT-LICENSE-AGREEMENT-4.0 Replace commercial preview license with Qt License Agreement 4.0 2018-06-21 11:39:15 +00:00
qtbase.pro nuke configure -host-option 2016-12-13 18:55:59 +00:00
sync.profile CMake: Add support for auto-importing plugins in CMake 2019-08-12 18:23:58 +02:00