summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-08-13 18:12:28 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-15 13:58:29 +0200
commit351904be50ce1b76b06aa2bad5c7f8ab8567ccfb (patch)
tree7b41359711818ebe46151bb69095d12970478723 /src
parent61fa926857c3e01eb7129b633d948f17db418f84 (diff)
Emit the highlighted signal if the model changes.
The bug is that the connection to emit that signal can be made obsolete if the connection is made too early and the model is replaced. In the bug report, the connection is made by calling view() early (thereby causing the creation of a view and a QItemSelectionModel which operates on the built-in QItemSelectionModel, and then connecting to that QItemSelectionModel), and then when QComboBox::setModel() is called later the built-in view creates a new QItemSelectionModel for it. The bug was that that new QItemSelectionModel is not connected to. This patch fixes that bug. Task-number: QTBUG-4454 Change-Id: Ibbdb8731f16ab071008b4a19dc2cc7ae03cebc84 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qcombobox.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 6a8e7b4641..6f927ab80b 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -1914,8 +1914,12 @@ void QComboBox::setModel(QAbstractItemModel *model)
connect(model, SIGNAL(modelReset()),
this, SLOT(_q_modelReset()));
- if (d->container)
+ if (d->container) {
d->container->itemView()->setModel(model);
+ connect(d->container->itemView()->selectionModel(),
+ SIGNAL(currentChanged(QModelIndex,QModelIndex)),
+ this, SLOT(_q_emitHighlighted(QModelIndex)), Qt::UniqueConnection);
+ }
bool currentReset = false;