Originally Posted by
ChrisW67
Setting the model column for the combo box does not change this.
Hmm... that's a bit strange since every code path I can see that leads to updating the combo's text goes through this method:
{
QModelIndex mi
= d
->model
->index
(index, d
->modelColumn, d
->root
);
return d->itemText(mi);
}
QString QComboBox::itemText(int index) const
{
Q_D(const QComboBox);
QModelIndex mi = d->model->index(index, d->modelColumn, d->root);
return d->itemText(mi);
}
To copy to clipboard, switch view to plain text mode
... which would suggest the column model should be respected.
Added after 12 minutes:
I'd say it's a bug in QComboBoxPrivate::setCurrentIndex.
It says:
void QComboBoxPrivate
::setCurrentIndex(const QModelIndex &mi
) {
bool indexChanged = (mi != currentIndex);
if (indexChanged)
if (lineEdit) {
QString newText
= q
->itemText
(currentIndex.
row());
if (lineEdit->text() != newText)
lineEdit->setText(newText);
updateLineEditGeometry();
}
if (indexChanged) {
q->update();
_q_emitCurrentIndexChanged(currentIndex);
}
}
void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi)
{
Q_Q(QComboBox);
bool indexChanged = (mi != currentIndex);
if (indexChanged)
currentIndex = QPersistentModelIndex(mi);
if (lineEdit) {
QString newText = q->itemText(currentIndex.row());
if (lineEdit->text() != newText)
lineEdit->setText(newText);
updateLineEditGeometry();
}
if (indexChanged) {
q->update();
_q_emitCurrentIndexChanged(currentIndex);
}
}
To copy to clipboard, switch view to plain text mode
and should be:
{
mi = model->index(mi.row(), modelColumn, mi.parent());
bool indexChanged = (mi != currentIndex);
if (indexChanged)
if (lineEdit) {
QString newText
= q
->itemText
(currentIndex.
row());
if (lineEdit->text() != newText)
lineEdit->setText(newText);
updateLineEditGeometry();
}
if (indexChanged) {
q->update();
_q_emitCurrentIndexChanged(currentIndex);
}
}
void QComboBoxPrivate::setCurrentIndex(QModelIndex mi)
{
Q_Q(QComboBox);
mi = model->index(mi.row(), modelColumn, mi.parent());
bool indexChanged = (mi != currentIndex);
if (indexChanged)
currentIndex = QPersistentModelIndex(mi);
if (lineEdit) {
QString newText = q->itemText(currentIndex.row());
if (lineEdit->text() != newText)
lineEdit->setText(newText);
updateLineEditGeometry();
}
if (indexChanged) {
q->update();
_q_emitCurrentIndexChanged(currentIndex);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks