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 can I add button inside treewidget/view?
Forum Updated to NodeBB v4.3 + New Features

How can I add button inside treewidget/view?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 3.6k Views 1 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.
  • G Offline
    G Offline
    Gokhan
    wrote on last edited by Gokhan
    #1

    Hi everyone,
    I wanna do a thing like the below image. A button (tool button) and text have to be in one cell. How can I do this? Which widget should I use Treewidget or treeview?

    alt text

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Hi! The image-upload feature on our forum is broken, you might see the images you uploaded but other users don't. Please upload your images to an image hoster of your choice, e.g. https://postimage.io/, and embed them here with the following markup: ![alternate text](url).

      "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

      G 1 Reply Last reply
      2
      • VRoninV VRonin

        Hi! The image-upload feature on our forum is broken, you might see the images you uploaded but other users don't. Please upload your images to an image hoster of your choice, e.g. https://postimage.io/, and embed them here with the following markup: ![alternate text](url).

        G Offline
        G Offline
        Gokhan
        wrote on last edited by
        #3

        @VRonin I guess it can be seen now?

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          Treewidget is just a treeview with an embedded model.

          What you need is a delegate, see http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html

          "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

          G 1 Reply Last reply
          2
          • VRoninV VRonin

            Treewidget is just a treeview with an embedded model.

            What you need is a delegate, see http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html

            G Offline
            G Offline
            Gokhan
            wrote on last edited by
            #5

            @VRonin It is a very complicated example, I really don't understand anything.

            mrjjM 1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              Ok, let's start from the overview of the framework: http://doc.qt.io/qt-5/model-view-programming.html

              "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
              • G Gokhan

                @VRonin It is a very complicated example, I really don't understand anything.

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

                @Gokhan
                Hi
                Sadly the model & view concept in Qt is not super easy to get started with.
                http://doc.qt.io/qt-5/model-view-programming.html

                The delegate is then a helper class to change how the View display data.
                I like the info here
                http://www.informit.com/articles/article.aspx?p=1405547&seqNum=4

                Delegates are the way to do it as they offer far better performance.

                However, there is also poor mans way using a
                Treewidget and
                http://doc.qt.io/qt-5/qlistwidget.html#setItemWidget

                which allows to insert normal widget into a cell
                BUT
                This get heavy fast if not on Desktop pc.

                So its better to spend some days reading about views and delegates than a fast hax.

                G 1 Reply Last reply
                6
                • mrjjM mrjj

                  @Gokhan
                  Hi
                  Sadly the model & view concept in Qt is not super easy to get started with.
                  http://doc.qt.io/qt-5/model-view-programming.html

                  The delegate is then a helper class to change how the View display data.
                  I like the info here
                  http://www.informit.com/articles/article.aspx?p=1405547&seqNum=4

                  Delegates are the way to do it as they offer far better performance.

                  However, there is also poor mans way using a
                  Treewidget and
                  http://doc.qt.io/qt-5/qlistwidget.html#setItemWidget

                  which allows to insert normal widget into a cell
                  BUT
                  This get heavy fast if not on Desktop pc.

                  So its better to spend some days reading about views and delegates than a fast hax.

                  G Offline
                  G Offline
                  Gokhan
                  wrote on last edited by
                  #8

                  @mrjj thank you. I did it easily after read your shared links. They're really good documents to get started with.

                  1 Reply Last reply
                  2

                  • Login

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