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. Is it possible to put input widgets inside a tree widget?
Forum Update on Monday, May 27th 2025

Is it possible to put input widgets inside a tree widget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 2.2k 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.
  • J Offline
    J Offline
    jonasqt
    wrote on 11 Jul 2017, 10:47 last edited by
    #1

    or is that only to organize lists?

    I want to put textboxes into each node of the tree but have the textboxes disappear when I fold together the tree. How can this be done?

    J 1 Reply Last reply 11 Jul 2017, 11:38
    0
    • J jonasqt
      11 Jul 2017, 10:47

      or is that only to organize lists?

      I want to put textboxes into each node of the tree but have the textboxes disappear when I fold together the tree. How can this be done?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 11 Jul 2017, 11:38 last edited by
      #2

      @jonasqt Sounds like you need http://doc.qt.io/qt-5/qtreewidget.html#setItemWidget

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      V J 2 Replies Last reply 11 Jul 2017, 12:17
      1
      • J jsulm
        11 Jul 2017, 11:38

        @jonasqt Sounds like you need http://doc.qt.io/qt-5/qtreewidget.html#setItemWidget

        V Offline
        V Offline
        VRonin
        wrote on 11 Jul 2017, 12:17 last edited by
        #3

        @jsulm Not sure I agree. here it's just about the delegate and the default delegate for ext is QTextEdit (which is what I guess you mean by "textboxes") so you really have to do nothing else than setting the edit QTreeWidget edit triggers http://doc.qt.io/qt-5/qabstractitemview.html#editTriggers-prop

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        1
        • J jsulm
          11 Jul 2017, 11:38

          @jonasqt Sounds like you need http://doc.qt.io/qt-5/qtreewidget.html#setItemWidget

          J Offline
          J Offline
          jonasqt
          wrote on 11 Jul 2017, 12:38 last edited by
          #4

          @jsulm the documentation says this only applies to static content. If I am waiting for the user to input a value or alter a combobox, would that be considered dynamic or static content?

          V 1 Reply Last reply 11 Jul 2017, 12:58
          0
          • J jonasqt
            11 Jul 2017, 12:38

            @jsulm the documentation says this only applies to static content. If I am waiting for the user to input a value or alter a combobox, would that be considered dynamic or static content?

            V Offline
            V Offline
            VRonin
            wrote on 11 Jul 2017, 12:58 last edited by
            #5

            @jonasqt said in Is it possible to put input widgets inside a tree widget?:

            If I am waiting for the user to input a value or alter a combobox

            Then what you need is a custom delegate. see http://doc.qt.io/qt-5/model-view-programming.html#delegate-classes and http://doc.qt.io/qt-5/qstyleditemdelegate.html

            Since you just need to determine the editor then you can probably just set an editor factory http://doc.qt.io/qt-5/qitemeditorfactory.html on a default delegate

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            J 1 Reply Last reply 11 Jul 2017, 14:01
            1
            • V VRonin
              11 Jul 2017, 12:58

              @jonasqt said in Is it possible to put input widgets inside a tree widget?:

              If I am waiting for the user to input a value or alter a combobox

              Then what you need is a custom delegate. see http://doc.qt.io/qt-5/model-view-programming.html#delegate-classes and http://doc.qt.io/qt-5/qstyleditemdelegate.html

              Since you just need to determine the editor then you can probably just set an editor factory http://doc.qt.io/qt-5/qitemeditorfactory.html on a default delegate

              J Offline
              J Offline
              jonasqt
              wrote on 11 Jul 2017, 14:01 last edited by jonasqt 7 Nov 2017, 14:02
              #6

              @VRonin I've just done it using setItemWIdget() of the TreeWidget and it's running and the user can enter something into the QTextEdit box.

              Why do I still need a custom delegate?

              V 1 Reply Last reply 11 Jul 2017, 14:22
              0
              • J jonasqt
                11 Jul 2017, 14:01

                @VRonin I've just done it using setItemWIdget() of the TreeWidget and it's running and the user can enter something into the QTextEdit box.

                Why do I still need a custom delegate?

                V Offline
                V Offline
                VRonin
                wrote on 11 Jul 2017, 14:22 last edited by
                #7

                It's not on top but a replacement. Your solution works when you have just a few elements in the tree, try to make it ~1000 lines and then scroll down, you'll notice the setItemWIdget solution is too inefficient

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                4

                2/7

                11 Jul 2017, 11:38

                topic:navigator.unread, 5
                • Login

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