Important: Please read the Qt Code of Conduct -

How to disable a qlistview item once it has been clicked

  • I need the clicked item on my QListView disabled when ever it is clicked once. Please I need help with this, thanks in advance

    QFileSystemModel *listModel = new QFileSystemModel(this);
    QString directory = GLBclusterPath;
    connect(ui->clusterList, &QAbstractItemView::clicked, this, &displayTable::nodeClicked);

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you mean make it "unclickable"/read-only ?

  • @SGaist Yes exactly

  • Lifetime Qt Champion

    Then you are going to have to either subclass QFileSystemModel or create a custom proxy model that will modify the flags as necessary.

    Note that this requirements sounds a bit strange. Why do you need that ?

  • Thank you @SGaist

  • @SGaist Basically, I have a list of files in a folder, the list view lists each of the files, on click of each of the file, a function nodeClicked() is activated which carries out a process using information contained in each file, however, after each item is selected it needs a wait time of about 20 seconds to finish the background process and display the information, the user might not know this and tried to click severally, this only increases the wait time. this is why I need the item "unclickable" after it has been clicked once

  • Lifetime Qt Champion

    Then you should consider giving more feedback to your users otherwise they are going to think that your application is broken. Something like changing the color of the cell they clicked. Have an additional column giving status information about what is happening with that file, etc.

  • What about a QProgressBar? So the User can see the Progress.

Log in to reply