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 make QTreeWidgetItem Unclickable
Forum Updated to NodeBB v4.3 + New Features

How to make QTreeWidgetItem Unclickable

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 2.1k Views 4 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.
  • M Offline
    M Offline
    MostafaEzzat
    wrote on 14 Feb 2019, 15:06 last edited by MostafaEzzat
    #1

    Hi , i have many QTreeWidgets also QTreeWidgetItems and i wanna make the parent in every QTreeWidget unclickable but the child is okey so i used

            item1_AddingItemstoTreeWidget_3->setFlags(item1_AddingItemstoTreeWidget_3->flags() &  ~Qt::ItemIsSelectable );
    
    

    but it makes the item clickable and if i click it gives NULL value and this makes the software crashes and the process as following : Two TreeWidgets in the page and if click an item in first one will be added to the second Tree then save it in database and This Null or empty block for Serum so i wanna make parents unclickable .. Thanks in Advance
    this an image : "https://ibb.co/qYThprS"

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 Feb 2019, 22:09 last edited by
      #2

      Hi,

      What is the stack trace of your crash ?

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

      M 1 Reply Last reply 15 Feb 2019, 14:46
      1
      • S SGaist
        14 Feb 2019, 22:09

        Hi,

        What is the stack trace of your crash ?

        M Offline
        M Offline
        MostafaEzzat
        wrote on 15 Feb 2019, 14:46 last edited by
        #3

        @SGaist
        Actually the second TreeWidget items appending in a vector so it inserted a NULL value that makes software crashes when i click "Cancel" button , so i wanna prevent this by make the parents unclickable (that if th user click not added not the second TreeWidget coz the first TreeWidget adding items by DoubleClick ) but all answers i found about disable and isSelectable and i tried them and don't serve my Request

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 15 Feb 2019, 15:15 last edited by
          #4

          Hi
          Did you try with removing
          Qt::ItemIsEnabled ?

          M 1 Reply Last reply 15 Feb 2019, 15:58
          1
          • M mrjj
            15 Feb 2019, 15:15

            Hi
            Did you try with removing
            Qt::ItemIsEnabled ?

            M Offline
            M Offline
            MostafaEzzat
            wrote on 15 Feb 2019, 15:58 last edited by MostafaEzzat
            #5

            @mrjj
            i tried this too , but i don't need isSelectable or isEnabled because it also makes the item clickable , Actually i have function for the first TreeWidget .. on_treeWidget_itemDoubleClicked()
            but i wanna only the parents be unclickable .. can this be achived ?
            this image after displaying Qt::ItemIsEnabled : "https://ibb.co/S0RSZ4q"

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 15 Feb 2019, 20:23 last edited by
              #6

              What about the solution proposed in this stack overflow thread ?

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

              M 1 Reply Last reply 17 Feb 2019, 14:25
              1
              • S SGaist
                15 Feb 2019, 20:23

                What about the solution proposed in this stack overflow thread ?

                M Offline
                M Offline
                MostafaEzzat
                wrote on 17 Feb 2019, 14:25 last edited by
                #7

                @SGaist
                i tried it after seeing on Stackoverflow from your comment but it didn't work either , also i saw a link for same request and used

                         item1_AddingItemstoTreeWidget_3->setFlags(item1_AddingItemstoTreeWidget_3->flags() &  ~Qt::NoItemFlags  );
                
                

                also didn't work

                1 Reply Last reply
                0

                7/7

                17 Feb 2019, 14:25

                • Login

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