Should use the selected item when it's interacted with using the mouse.
Details
- Reviewers
davidedmundson - Group Reviewers
Frameworks - Commits
- R858:cb49b355f946: ComboBox: fix default delegate
Selecting an item from the test combo box works now
Diff Detail
- Repository
- R858 Qt Quick Controls 2: Desktop Style
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
org.kde.desktop/ComboBox.qml | ||
---|---|---|
58 | Are you sure this is needed? Qt docs say for that using ItemDelegate for a ComboBox is recommended as: |
org.kde.desktop/ComboBox.qml | ||
---|---|---|
58 | otherwise it didn't work. I may have overlooked something though. |
I checked Qt source code and Qt indeed should handle this on its own, it also works fine hwere without the code.
Worse, the explicit assignment from QML breaks any binding set on currentIndex.
In the handler that's called when the delegate model creates a delegate it does the following
void QQuickComboBoxPrivate::createdItem(int index, QObject *object) { ... QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton *>(object); if (button) { button->setFocusPolicy(Qt::NoFocus); connect(button, &QQuickAbstractButton::clicked, this, &QQuickComboBoxPrivate::itemClicked); connect(button, &QQuickAbstractButton::hoveredChanged, this, &QQuickComboBoxPrivate::itemHovered); }
ItemDelegate is an AbstractButton and in itemClicked it sets the currentIndex and emits activated.