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. How to disable a qlistview item once it has been clicked
Qt 6.11 is out! See what's new in the release blog

How to disable a qlistview item once it has been clicked

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.9k 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.
  • B Offline
    B Offline
    Blavida
    wrote on last edited by Blavida
    #1

    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;
    ui->clusterList->setModel(listModel);
    ui->clusterList->setRootIndex(listModel->setRootPath(directory));
    connect(ui->clusterList, &QAbstractItemView::clicked, this, &displayTable::nodeClicked);
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

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

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

      B 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

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

        B Offline
        B Offline
        Blavida
        wrote on last edited by
        #3

        @SGaist Yes exactly

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

          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 ?

          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
          • B Offline
            B Offline
            Blavida
            wrote on last edited by
            #5

            Thank you @SGaist

            1 Reply Last reply
            0
            • B Offline
              B Offline
              Blavida
              wrote on last edited by
              #6

              @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

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

                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.

                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
                • Fuel 0F Offline
                  Fuel 0F Offline
                  Fuel 0
                  wrote on last edited by
                  #8

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

                  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