I have solved this problem, qt has a clicked signal function that emitted when a mouse button is clicked. The item the mouse was clicked on is specified by index. The signal is only emitted when the index is valid.

Qt Code:
  1. connect(ui->listView_Group,SIGNAL(clicked(const QModelIndex &)),this,SLOT(selectionChanged(const QModelIndex &)));
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. void MusicSettingsWidget::selectionChanged(const QModelIndex & index)
  2. {
  3. if ( index.data().toString() != "all music" ){
  4. musicSettings4a6ConfigFile->beginGroup("GroupList");
  5. QStringList musicList;
  6. musicList << musicSettings4a6ConfigFile->value(index.data().toString()).toString().split(";",QString::SkipEmptyParts);
  7. musicSettings4a6ConfigFile->endGroup();
  8. mp3ListModel->setStringList(musicList);
  9. ui->listView->setModel(mp3ListModel);
  10. ui->listView->selectAll();
  11. }else{
  12. mp3ListInit();
  13. }
  14. }
To copy to clipboard, switch view to plain text mode