QListView get clicked item
-
wrote on 19 Oct 2018, 14:30 last edited by
-
Hi
Depending on how fancy you want to be.
You could use
http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html
as a base and make a delegate so user can directly press star on row in "All" to
mark it a favorite. ( and also show if it is)The less involving version is to use
a button and a UserRole for storing if its a favorite in the model.
http://doc.qt.io/qt-5/qabstractitemmodel.html#setData
http://doc.qt.io/qt-5/modelview.html -
Hi
Depending on how fancy you want to be.
You could use
http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html
as a base and make a delegate so user can directly press star on row in "All" to
mark it a favorite. ( and also show if it is)The less involving version is to use
a button and a UserRole for storing if its a favorite in the model.
http://doc.qt.io/qt-5/qabstractitemmodel.html#setData
http://doc.qt.io/qt-5/modelview.htmlwrote on 19 Oct 2018, 15:08 last edited by@mrjj i am already using the playlist model of qt media player example : media player but i don't know how to get the selected item from the listview of the playlist
-
@mrjj i am already using the playlist model of qt media player example : media player but i don't know how to get the selected item from the listview of the playlist
@HW-Developer
Hi
Well you can do like this
QModelIndex index = ui->listView->currentIndex();
QString itemText = index.data(Qt::DisplayRole).toString();
to get its text. -
@HW-Developer
Hi
Well you can do like this
QModelIndex index = ui->listView->currentIndex();
QString itemText = index.data(Qt::DisplayRole).toString();
to get its text.wrote on 22 Oct 2018, 11:08 last edited by@mrjj Thank you for your help and have a good day
1/5