不确定如何显示列表中单击的项目或索引?
{
...
nrow = 10;
ncol = 1;
/*create QListView */
m_listView = new QListView(this);
m_listView->setGeometry(QRect(QPoint(0,100), QSize(100, 150)));
connect(m_listView, SIGNAL(clicked(QModelIndex)), this, SLOT(hItem()));
QStandardItemModel *model = new QStandardItemModel( nrow, 1, this );
//fill model value
for( int r=0; r<nrow; r++ )
{
QString sstr = "[ " + QString::number(r) + " ]";
QStandardItem *item = new QStandardItem(QString("Idx ") + sstr);
model->setItem(r, 0, item);
}
}
void MainWindow::hItem()
{
m_txt1->setText(item@clicked);
}