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 using only QtQuick 2 works fine?
QtWS25 Last Chance

QML TreeView using only QtQuick 2 works fine?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 4 Posters 1.7k 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.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi.
    Quite a few people, including myself, have been regretting and wondering why TreeView is only available in Controls 1 which are deprecated since Qt 5.12.

    As it turns out however, it seems quite straight-forward to adapt the TreeView code to depend exclusively on Controls 2 elements.

    For instance, I just copied and merged all the QML code for a TreeView into a single .qml file that only depends on the following imports:

    import QtQuick 2.15
    import QtQuick.Controls 2.15
    import QtQml.Models 2.15
    

    A working TreeView then only requires a local copy of the original TableViewColumn.qml file (which itself only depends on the QtQuick 2.15 module), and a local copy of the QQuickTreeModelAdaptor class source (which simply implements a QAbstractListModel)

    Internally, the original TreeView uses ScrollView, ListView and FocusScope, all of which have their equivalents in QtQuick2 (the only property I needed to comment out was the frameVisible property, which does not exist in ScrollView 2, and get rid of the viewport property).

    Aside from the styling parts which I either eliminated or hard-coded,
    and the scrollbar code which I currently disabled, it seems to work just fine: the tree displays, expands/collapses and behaves as expected, so far.

    I wanted to upload the code for that self-contained TreeView.qml file here, but unfortunately, posts are not allowed to be that long.

    1 Reply Last reply
    1
    • M Offline
      M Offline
      mnesarco
      wrote on last edited by
      #2

      That sounds great. Can you share it via Github?

      DiracsbracketD 1 Reply Last reply
      0
      • M mnesarco

        That sounds great. Can you share it via Github?

        DiracsbracketD Offline
        DiracsbracketD Offline
        Diracsbracket
        wrote on last edited by Diracsbracket
        #3

        @mnesarco said in QML TreeView using only QtQuick 2 just works fine?:

        Can you share it via Github?

        I uploaded the filesystembrowser example using the modified TreeView here:
        https://github.com/diracsbracket/qmltreeview2

        1 Reply Last reply
        2
        • M Offline
          M Offline
          maxwell31
          wrote on last edited by
          #4

          A questions: Is it possible to make a copy of QQuickTreeModelAdaptor in a LGPL licensed program or would this violate the LGPL?

          jsulmJ 1 Reply Last reply
          0
          • M maxwell31

            A questions: Is it possible to make a copy of QQuickTreeModelAdaptor in a LGPL licensed program or would this violate the LGPL?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @maxwell31 What exactly do you mean? Do you want to modify QQuickTreeModelAdaptor? Or why else you would need to "copy"?
            If you want to modify QQuickTreeModelAdaptor then you have ot make your changes open source (LGPL requirement).

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

            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