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

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 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?

    jsulmJ 1 Reply Last reply
    0
    • J jonasqt

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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

      VRoninV J 2 Replies Last reply
      1
      • jsulmJ jsulm

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

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on 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
        • jsulmJ jsulm

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

          J Offline
          J Offline
          jonasqt
          wrote on 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?

          VRoninV 1 Reply Last reply
          0
          • J jonasqt

            @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?

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on 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
            1
            • VRoninV VRonin

              @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 last edited by jonasqt
              #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?

              VRoninV 1 Reply Last reply
              0
              • J jonasqt

                @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?

                VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on 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

                • Login

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