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

QComboBox's QCompleter does not change currentIndex() after selection from its popup list

    XMLWordPrintable

Details

    Description

      Test case
      1) create a editable QComboBox
      2) enter into QComboBox , a partial match for a value in qcombox , eg "Firs"
      3) in the QCompleter popup the list and select with mouse a chose in popup
      4) QComboBox::currentIndex() idealy be changed to suit the selection made with mouse, however selection can be accepted by pressing <Enter> on the keyboard

      Workarounds offered :

      #1 to get the real selected index you can match the current text of the combobox in the model
      QModelIndexList list = combobox->model()->match(
      combobox->model()->index( 0, 0 ), Qt::DisplayRole,
      combobox->currentText(), 1, Qt::MatchExactly );
      if( list.size() > 0 )
      ...

      #2 you can also connect to the activated signal of the completer
      QObject::connect(cb->completer(), SIGNAL(activated(QString)), lineEdit, SLOT(setText(QString)));

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            isdale Keith Isdale (closed Nokia identity) (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes