How can i search selected lines one by one in a QTreeView and get their text
Hello
I have a QTreeView which calls the setModel function and gets a QStandardItemModel (e.g usersModel) to get the data inside it.
Is there any way to search all the lines in the tree one by one to find which are selected,and get the text of that lines,when i click on a PushButton??
Thanks
Re: How can i search selected lines one by one in a QTreeView and get their text
Re: How can i search selected lines one by one in a QTreeView and get their text
Hello jpn
I saw it but i can't understand how to implement it in my code
here is an example code:
Code:
Models *model;
usersTree->setModel(model->usersModel);//usersModel returns a QStandardItemModel
ok i got the users displayed in the tree.
assume there is a slot btnClicked when i push a button,and inside this slot i have to implement the searching of the selected rows one by one from usersTree,and get their data.
Can someone give me 3-4-5 lines,having in mind the example code, of how to do that?
Thank you
Re: How can i search selected lines one by one in a QTreeView and get their text
Code:
QModelIndexList indexes = usersTree->selectionModel()->selectedIndexes();
{
qDebug() << index.data(Qt::DisplayRole).toString();
}
Re: How can i search selected lines one by one in a QTreeView and get their text
Thanks jpn
that worked ;)
take care