QListView get clicked item
-
I am trying to build a media player app (Look at the screenshot below):
all is good for now, but i am having an issue to add a media selected from playlistview and add it to the list of favorites.
If any can help me with some ideas i really apreciate it thanks a lot -
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 -
@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.