diff options
author | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2010-05-25 18:09:00 (GMT) |
---|---|---|
committer | Qt Commercial Integration <QtCommercial@digia.com> | 2012-01-31 10:24:51 (GMT) |
commit | 1e8a1b289a1333b9e6887c4242e576be695e5857 (patch) | |
tree | f2e1d3ee2c98aa82bb9fa0dcff6a21c21986e1b9 /src | |
parent | bdaf3903545e9f1fbd70008ad6a506a650e1afb8 (diff) | |
download | Qt-1e8a1b289a1333b9e6887c4242e576be695e5857.zip Qt-1e8a1b289a1333b9e6887c4242e576be695e5857.tar.gz Qt-1e8a1b289a1333b9e6887c4242e576be695e5857.tar.bz2 |
QComboBox::modelColumn was not respected when selecting an item
Auto-test included
Reviewed-by: Olivier
Task-number: QTBUG-10491
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/qcombobox.cpp | 13 | ||||
-rw-r--r-- | src/gui/widgets/qcombobox_p.h | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 8a69bdf..8f2cbff 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -2013,11 +2013,18 @@ void QComboBox::setCurrentIndex(int index) void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) { Q_Q(QComboBox); - bool indexChanged = (mi != currentIndex); + + QModelIndex normalized; + if (mi.column() != modelColumn) + normalized = model->index(mi.row(), modelColumn, mi.parent()); + if (!normalized.isValid()) + normalized = mi; // Fallback to passed index. + + bool indexChanged = (normalized != currentIndex); if (indexChanged) - currentIndex = QPersistentModelIndex(mi); + currentIndex = QPersistentModelIndex(normalized); if (lineEdit) { - QString newText = q->itemText(currentIndex.row()); + QString newText = q->itemText(normalized.row()); if (lineEdit->text() != newText) lineEdit->setText(newText); updateLineEditGeometry(); diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index e1bb1fb..a17f9d9 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -337,7 +337,7 @@ private: QComboBox *mCombo; }; -class QComboBoxPrivate : public QWidgetPrivate +class Q_AUTOTEST_EXPORT QComboBoxPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QComboBox) public: |