Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-10491

QComboBox does not respect modelColumn() when using a multi column itemview as popup

    XMLWordPrintable

Details

    • 00edad4373d394ed9f828b1fa887003f87c5fa6f

    Description

      When using a multicolumn view choosing a item from the popup will does not respect modelColumn(), instead it shows the selected column
      in the combobox.
      The problem comes from QComboBoxPrivateContainer::eventFilter because it passes the selected modelindex instead of creating a own
      with the selected row and modelColumn().
      Alternatively QComboBoxPrivate::setCurrentIndex could recreate the passed index with the modelColumn:

      changed setCurrentIndex
      void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi)
      {
          Q_Q(QComboBox);
      
          QModelIndex normalized = q->model()->index(mi.row(),q->modelColumn(),mi.parent());
          if(!normalized.isValid())
               normalized = mi;    //fallback to passed index
      
          bool indexChanged = (normalized!= currentIndex);
          if (indexChanged)
              currentIndex = QPersistentModelIndex(normalized);
          if (lineEdit) {
              QString newText = q->itemText(normalized.row());
              if (lineEdit->text() != newText)
                  lineEdit->setText(newText);
              updateLineEditGeometry();
          }
          if (indexChanged) {
              q->update();
              _q_emitCurrentIndexChanged(currentIndex);
          }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dedietri Gabriel de Dietrich (drgvond)
            zbenjamin Benjamin Zeller
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes