我需要将所选行的数量(在on_listView_clicked中)分配给int变量。我试过int variable1 = index.row();但它不起作用。有人可以帮忙吗?
List_qt::List_qt(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
model = new QStringListModel(this);
QStringList List;
List << "Some Item1" << "Some Item2" << "Some Item3";
model->setStringList(List)
ui.listView->setModel(model);
}
void List_qt::on_listView_clicked(const QModelIndex &index)
{
int variable1 = index.row(); // this part of code can be compile but doesn't works after running application
}