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. [SOLVED] Handle QListWidget click
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Handle QListWidget click

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello,

    I have would like to handle a click in QListWidget. When I click on some other song, current song should stop playing and clicked one should start.

    I connected SIGNAL clicked with my slot, but don't know how to get index of clicked item and then send that to player...

    @connect(ui->listWidget1, SIGNAL(clicked(QModelIndex)), this, SLOT(updateSong()));@

    !http://imageshack.us/a/img194/6610/rplh.png(img)!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      the QModelIndex does exactly that, it allows you to retrieve the information from the model.

      Have a look at the Model/View documentation to see how it can be used

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        SOLVED!

        @QModelIndex ind = ui->listWidget1->currentIndex();
        if(!ind.isValid())
        return;
        playlist->setCurrentIndex(ind.row());@

        1 Reply Last reply
        0

        • Login

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