Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QListView get clicked item

QListView get clicked item

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 7.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HW-Developer
    wrote on 19 Oct 2018, 14:30 last edited by
    #1

    I am trying to build a media player app (Look at the screenshot below):
    0_1539959437287_Capture.PNG
    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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 19 Oct 2018, 14:41 last edited by
      #2

      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

      H 1 Reply Last reply 19 Oct 2018, 15:08
      4
      • M mrjj
        19 Oct 2018, 14:41

        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

        H Offline
        H Offline
        HW-Developer
        wrote on 19 Oct 2018, 15:08 last edited by
        #3

        @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

        M 1 Reply Last reply 19 Oct 2018, 15:29
        0
        • H HW-Developer
          19 Oct 2018, 15:08

          @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

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 19 Oct 2018, 15:29 last edited by
          #4

          @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.

          H 1 Reply Last reply 22 Oct 2018, 11:08
          2
          • M mrjj
            19 Oct 2018, 15:29

            @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.

            H Offline
            H Offline
            HW-Developer
            wrote on 22 Oct 2018, 11:08 last edited by
            #5

            @mrjj Thank you for your help and have a good day

            1 Reply Last reply
            1

            3/5

            19 Oct 2018, 15:08

            • Login

            • Login or register to search.
            3 out of 5
            • First post
              3/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved