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
QtWS25 Last Chance

How to disable items selected in Qtreeview

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 2.0k 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on 18 Sept 2018, 13:22 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 18 Sept 2018, 13:51 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 18 Sept 2018, 14:12 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

        J 1 Reply Last reply 18 Sept 2018, 14:21
        0
        • Q Qt Enthusiast
          18 Sept 2018, 14:12

          @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

          J Offline
          J Offline
          JonB
          wrote on 18 Sept 2018, 14:21 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 18 Sept 2018, 15:04 last edited by
            #5

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

            M 1 Reply Last reply 19 Sept 2018, 15:03
            0
            • Q Qt Enthusiast
              18 Sept 2018, 15:04

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

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 19 Sept 2018, 15:03 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

              1/6

              18 Sept 2018, 13:22

              • Login

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