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
Forum Updated to NodeBB v4.3 + New Features

QListView get clicked item

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 7.7k Views 1 Watching
  • 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 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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
      4
      • mrjjM mrjj

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

        mrjjM 1 Reply Last reply
        0
        • H HW-Developer

          @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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on 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
          2
          • mrjjM mrjj

            @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 last edited by
            #5

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

            1 Reply Last reply
            1

            • Login

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