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

How to disable items selected in Qtreeview

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 2.0k Views 2 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    I am adding a row in Qtreeview and I have to disable pop up menu on that row in Qtreeview . Can some one guide me on that

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TobbY
      wrote on last edited by TobbY
      #2

      Hi,

      You can do it simply add condition on OnDoubleClick

      TreeViewPage::OnDoubleClick(const QModelIndex& i_indexMode)
      {
      if (i_indexMode.row() == disabled_row_num) return;
      
         QDialog*  dlg= new QDialog(this);
         dlg->exec();
         delete dlg;
      }
      
      1 Reply Last reply
      1
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #3

        @TobbY said in How to disable items selected in Qtreeview:

        OnDoubleClick

        I am asking for conditions which flags to set to disable a QTreeview item

        JonBJ 1 Reply Last reply
        0
        • Q Qt Enthusiast

          @TobbY said in How to disable items selected in Qtreeview:

          OnDoubleClick

          I am asking for conditions which flags to set to disable a QTreeview item

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Qt-Enthusiast
          What "pop up menu on that row"? Do you have a custom right-click menu?

          1 Reply Last reply
          1
          • Q Offline
            Q Offline
            Qt Enthusiast
            wrote on last edited by
            #5

            I want one row on QTreeView to be which cannot be selected and Right click on it

            mrjjM 1 Reply Last reply
            0
            • Q Qt Enthusiast

              I want one row on QTreeView to be which cannot be selected and Right click on it

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              Pr item , you can disable
              item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
              If using a model, you can control from its Flags function
              http://doc.qt.io//qt-5/qstandarditemmodel.html#flags

              1 Reply Last reply
              4

              • Login

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