Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Need help for a TreeView
Forum Updated to NodeBB v4.3 + New Features

Need help for a TreeView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
30 Posts 3 Posters 9.8k Views 2 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.
  • EddyE Offline
    EddyE Offline
    Eddy
    wrote on last edited by
    #6

    I don't think that will work. Do you see your image after drag and drop?
    At least I don't see it over here.

    please follow the instructions in this link
    to show us your picture, otherwise it will be difficult to help you out.

    Eddy

    Qt Certified Specialist
    www.edalsolutions.be

    A 1 Reply Last reply
    0
    • EddyE Eddy

      I don't think that will work. Do you see your image after drag and drop?
      At least I don't see it over here.

      please follow the instructions in this link
      to show us your picture, otherwise it will be difficult to help you out.

      Eddy

      A Offline
      A Offline
      Arkning
      wrote on last edited by
      #7

      @Eddy Yes I see It (the picture is inside the first message), but It's an image from my computer not from internet so url doesn't work

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fheanor
        wrote on last edited by
        #8

        Upload it on internet and share it to us, it will be more easier I think

        A 1 Reply Last reply
        0
        • F Fheanor

          Upload it on internet and share it to us, it will be more easier I think

          A Offline
          A Offline
          Arkning
          wrote on last edited by Arkning
          #9

          @Fheanor https://www.google.fr/search?q=arborescence&source=lnms&tbm=isch&sa=X&ved=0ahUKEwie0IjOtPbTAhUKJlAKHdl6DaEQ_AUICigB&biw=1920&bih=908#imgrc=IYXrqFXnP7ShfM:

          I try with an url but it didn't work so here is a link to a photo on google image that show what I want.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Fheanor
            wrote on last edited by
            #10

            Looks like you have to use a TreeView with Rectangle Delegate on each line

            A 1 Reply Last reply
            0
            • F Fheanor

              Looks like you have to use a TreeView with Rectangle Delegate on each line

              A Offline
              A Offline
              Arkning
              wrote on last edited by
              #11

              @Fheanor Thanks for the answer do you have a code example ?

              1 Reply Last reply
              0
              • F Offline
                F Offline
                Fheanor
                wrote on last edited by Fheanor
                #12

                I don't have an example that correspond to your example, but these are two examples of how you can use Delegate inside a TreeView.

                • You can use the itemDelegate property of a TreeView . This example will change the color of each line:
                itemDelegate: Rectangle {
                       color: ( styleData.row % 2 == 0 ) ? "white" : "lightblue"
                       Text {
                           anchors.verticalCenter: parent.verticalCenter
                           anchors.left: parent.left
                           text: styleData.value // this points to the role we defined in the TableViewColumn below; which one depends on which column this delegate is instantiated for.
                       }
                }
                
                • You can also define a special Delegate for each column of your TreeView like that:
                TableViewColumn {
                       id : someColumn
                       role: "someRole"
                       title: someRole
                       delegate : Rectangle {
                           ...
                     }
                }
                

                Now you have to play with this to draw what you want

                A 1 Reply Last reply
                0
                • F Fheanor

                  I don't have an example that correspond to your example, but these are two examples of how you can use Delegate inside a TreeView.

                  • You can use the itemDelegate property of a TreeView . This example will change the color of each line:
                  itemDelegate: Rectangle {
                         color: ( styleData.row % 2 == 0 ) ? "white" : "lightblue"
                         Text {
                             anchors.verticalCenter: parent.verticalCenter
                             anchors.left: parent.left
                             text: styleData.value // this points to the role we defined in the TableViewColumn below; which one depends on which column this delegate is instantiated for.
                         }
                  }
                  
                  • You can also define a special Delegate for each column of your TreeView like that:
                  TableViewColumn {
                         id : someColumn
                         role: "someRole"
                         title: someRole
                         delegate : Rectangle {
                             ...
                       }
                  }
                  

                  Now you have to play with this to draw what you want

                  A Offline
                  A Offline
                  Arkning
                  wrote on last edited by Arkning
                  #13

                  @Fheanor Ok thanks i'll try I will let you know about my situation. Again thanks for the answers and your time !

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    Fheanor
                    wrote on last edited by
                    #14

                    You are welcome :)

                    A 1 Reply Last reply
                    0
                    • F Fheanor

                      You are welcome :)

                      A Offline
                      A Offline
                      Arkning
                      wrote on last edited by
                      #15

                      @Fheanor Hi, so I didn't manage to make it work, now just forget about the Rectangle thing, I just want to make a Treeview so can you help me ?

                      F 1 Reply Last reply
                      0
                      • A Arkning

                        @Fheanor Hi, so I didn't manage to make it work, now just forget about the Rectangle thing, I just want to make a Treeview so can you help me ?

                        F Offline
                        F Offline
                        Fheanor
                        wrote on last edited by
                        #16

                        @Arkning You need to share what you try to do so we can help you. What is not working when you try to make a TreeView ?
                        This example that was linked before works perfectly.

                        A 1 Reply Last reply
                        0
                        • F Fheanor

                          @Arkning You need to share what you try to do so we can help you. What is not working when you try to make a TreeView ?
                          This example that was linked before works perfectly.

                          A Offline
                          A Offline
                          Arkning
                          wrote on last edited by
                          #17

                          @Fheanor I have some assigning the model value, the example that you gave me the TableViewColumn part work but not the model one, Qt tell me that fileSystemModel doesn't exist. Actually I just want to add some "node" or p"parent" to my Treeview and of course some "children" I suppose it has a link with the model but I don't know how to do it. Hope it is more clear now. Thanks again for your time !

                          F 1 Reply Last reply
                          0
                          • A Arkning

                            @Fheanor I have some assigning the model value, the example that you gave me the TableViewColumn part work but not the model one, Qt tell me that fileSystemModel doesn't exist. Actually I just want to add some "node" or p"parent" to my Treeview and of course some "children" I suppose it has a link with the model but I don't know how to do it. Hope it is more clear now. Thanks again for your time !

                            F Offline
                            F Offline
                            Fheanor
                            wrote on last edited by
                            #18

                            @Arkning
                            This example is in your QtExample folder.
                            Just open your IDE, click on Examples and then write : TreeView. You will see the project.

                            A 1 Reply Last reply
                            0
                            • F Fheanor

                              @Arkning
                              This example is in your QtExample folder.
                              Just open your IDE, click on Examples and then write : TreeView. You will see the project.

                              A Offline
                              A Offline
                              Arkning
                              wrote on last edited by
                              #19

                              @Fheanor I don't have Examples on my IDE... Where should it be on the screen ?

                              F 1 Reply Last reply
                              0
                              • F Offline
                                F Offline
                                Fheanor
                                wrote on last edited by
                                #20

                                You can also create a TreeModel in C++ and then bind it to your Qml TreeView :

                                model: myTreeModel
                                

                                If you don't understand how to bind model and view, have a look on this

                                F 1 Reply Last reply
                                0
                                • A Arkning

                                  @Fheanor I don't have Examples on my IDE... Where should it be on the screen ?

                                  F Offline
                                  F Offline
                                  Fheanor
                                  wrote on last edited by Fheanor
                                  #21

                                  @Arkning Do you use QtCreator ? Because there are Examples folders in it.
                                  If you don't use it, download and install QtCreator.

                                  A 1 Reply Last reply
                                  0
                                  • F Fheanor

                                    @Arkning Do you use QtCreator ? Because there are Examples folders in it.
                                    If you don't use it, download and install QtCreator.

                                    A Offline
                                    A Offline
                                    Arkning
                                    wrote on last edited by
                                    #22

                                    @Fheanor Yes I'm using QtCreator

                                    F 1 Reply Last reply
                                    0
                                    • A Arkning

                                      @Fheanor Yes I'm using QtCreator

                                      F Offline
                                      F Offline
                                      Fheanor
                                      wrote on last edited by
                                      #23

                                      @Arkning This is on the Welcome page of your IDE... There is an Example Button

                                      A 1 Reply Last reply
                                      0
                                      • F Fheanor

                                        @Arkning This is on the Welcome page of your IDE... There is an Example Button

                                        A Offline
                                        A Offline
                                        Arkning
                                        wrote on last edited by
                                        #24

                                        @Fheanor Ok I found it but how can it help me ? I don't see were they create parent or children.

                                        1 Reply Last reply
                                        0
                                        • F Fheanor

                                          You can also create a TreeModel in C++ and then bind it to your Qml TreeView :

                                          model: myTreeModel
                                          

                                          If you don't understand how to bind model and view, have a look on this

                                          F Offline
                                          F Offline
                                          Fheanor
                                          wrote on last edited by
                                          #25

                                          @Fheanor said in Need help for a TreeView:

                                          You can also create a TreeModel in C++ and then bind it to your Qml TreeView :

                                          model: myTreeModel
                                          

                                          If you don't understand how to bind model and view, have a look on this

                                          A 1 Reply Last reply
                                          0

                                          • Login

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