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. QML TreeView
Forum Updated to NodeBB v4.3 + New Features

QML TreeView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 2 Posters 613 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.
  • V Offline
    V Offline
    VeNToR
    wrote on last edited by
    #1

    Hi;

    What is the correct and easy way to display nested items with model in TreeView without C++ ?

    Thanks...

    B 1 Reply Last reply
    0
    • V VeNToR

      Hi;

      What is the correct and easy way to display nested items with model in TreeView without C++ ?

      Thanks...

      B Offline
      B Offline
      Bob64
      wrote on last edited by
      #2

      @VeNToR There is no built-in way in QML to do this. You have to have a QAbstractItemModel implementation. I recall seeing people discussing making a reusable model implementation that can be configured from data defined in QML but unless you can find something like this ready made somewhere, you will have to implement something in C++.

      V 1 Reply Last reply
      0
      • B Bob64

        @VeNToR There is no built-in way in QML to do this. You have to have a QAbstractItemModel implementation. I recall seeing people discussing making a reusable model implementation that can be configured from data defined in QML but unless you can find something like this ready made somewhere, you will have to implement something in C++.

        V Offline
        V Offline
        VeNToR
        wrote on last edited by
        #3

        @Bob64 Thanks for your replay... I was think same as you, but I've tried to find a way... Thanks again...

        V 1 Reply Last reply
        0
        • V VeNToR

          @Bob64 Thanks for your replay... I was think same as you, but I've tried to find a way... Thanks again...

          V Offline
          V Offline
          VeNToR
          wrote on last edited by
          #4

          @VeNToR This way is so long, It should not be hard as using QAbstractItemModel.

          for following model....

          ListModel
          {
          	id			:	chModel
          
          	ListElement
          	{		
          		text		:	"1"
          
          		elements	:	[
          							ListElement
          							{
          								text		:	"1.1"
          							}
          					]
          	}
          }
          
          B 1 Reply Last reply
          0
          • V VeNToR

            @VeNToR This way is so long, It should not be hard as using QAbstractItemModel.

            for following model....

            ListModel
            {
            	id			:	chModel
            
            	ListElement
            	{		
            		text		:	"1"
            
            		elements	:	[
            							ListElement
            							{
            								text		:	"1.1"
            							}
            					]
            	}
            }
            
            B Offline
            B Offline
            Bob64
            wrote on last edited by
            #5

            @VeNToR TreeView can be quite daunting when first encountered, especially if you are new to QML and Qt. It can be useful to start with an example that someone has already made and try to make changes that make it closer to your requirements. This should help you to understand how to implement a model. You might either end up gradually adapting it to what you need, or at some point you will be sufficiently confident to start from scratch based on the knowledge you have gained.

            If I remember correctly, this is one I referred to myself when I started out. I believe it's an adaptation to QML of one of Qt's own C++ QWidgets examples.

            V 1 Reply Last reply
            1
            • B Bob64

              @VeNToR TreeView can be quite daunting when first encountered, especially if you are new to QML and Qt. It can be useful to start with an example that someone has already made and try to make changes that make it closer to your requirements. This should help you to understand how to implement a model. You might either end up gradually adapting it to what you need, or at some point you will be sufficiently confident to start from scratch based on the knowledge you have gained.

              If I remember correctly, this is one I referred to myself when I started out. I believe it's an adaptation to QML of one of Qt's own C++ QWidgets examples.

              V Offline
              V Offline
              VeNToR
              wrote on last edited by VeNToR
              #6

              @Bob64 Thank you again... I'm not new on Qt and QML, but this is first time to use TreeView :) On the other hand, how can I extent my extension as ListElement feature like dynamic role ?
              like follows;

              MyElement
              {
              myRole : "test"
              .
              ..
              ...
              }

              "myRole" is dynamic (you can add many...), but my extension's must be defined by Q_PROPERTY.

              when I use any undefined role/property by Q_PROPERTY, I get this "Cannot assign to non-existent property" error.

              B 1 Reply Last reply
              0
              • V VeNToR

                @Bob64 Thank you again... I'm not new on Qt and QML, but this is first time to use TreeView :) On the other hand, how can I extent my extension as ListElement feature like dynamic role ?
                like follows;

                MyElement
                {
                myRole : "test"
                .
                ..
                ...
                }

                "myRole" is dynamic (you can add many...), but my extension's must be defined by Q_PROPERTY.

                when I use any undefined role/property by Q_PROPERTY, I get this "Cannot assign to non-existent property" error.

                B Offline
                B Offline
                Bob64
                wrote on last edited by
                #7

                @VeNToR I am really sorry but I don't think I understand well enough what you are trying to achieve to be able to make any sensible suggestions.

                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