如何在QCompleter中获取所选项目的原始索引?

时间:2019-08-02 15:26:00

标签: qt qlineedit qstandarditemmodel qcompleter qmodelindex

我有一个与clipChildren="false"集成的LineEdit,Completer的视图为QCompleter,该视图具有对项目进行排序的能力,Completer的模型为QTreeView

QStandardItemModel

选择一个项目后,我会使用此信号。

MyLineEdit::MyLineEdit( QWidget *p_parent ) : QLineEdit( p_parent )
{
  m_completer = new QCompleter( this );
  m_completer->setCaseSensitivity( Qt::CaseInsensitive );
  m_sourceModel = new QStandardItemModel( m_completer );
  ..........   //import data for model
  m_view = new QTreeView();
  m_view->setSortingEnabled(true);
  m_completer->setPopup( m_view );
  m_completer->setModel( m_sourceModel );
  setCompleter( m_completer );
}

如何在此处获取所选索引的原始索引?

0 个答案:

没有答案