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. QTreeView QML plugin with QFileSystemModel
Forum Updated to NodeBB v4.3 + New Features

QTreeView QML plugin with QFileSystemModel

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 5.2k 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.
  • U Offline
    U Offline
    ultramanjones
    wrote on 12 Jul 2012, 19:59 last edited by
    #1

    Hello everybody. I'm trying to incorporate a Model/View into an application using QTreeView, QFileSystemModel and qmlRegisterType to create the QTreeView plugin.

    If my main.qml looks like this:

    @import QtQuick 1.1
    import TreeView_Plugin 1.0

    TreeView {
        id: myTreeView
        allColumnsShowFocus: true
    
    }@
    

    I get a QTreeView displayed looking like this:

    !http://1.bp.blogspot.com/-dtR8D2YWe1s/T_8mm21zLFI/AAAAAAAACfw/8LURCRfSXss/s1600/TreeView01.jpg(QTreeView alone)!

    However, when my main.qml looks like this:

    @import QtQuick 1.1
    import TreeView_Plugin 1.0

    Rectangle {
    id:myRect
    width: 400
    height: 400

    TreeView {
        id: myTreeView
        allColumnsShowFocus: true
    
    }
    

    }@

    All I get is this...
    !http://4.bp.blogspot.com/-VGPBBJWf4p0/T_8ou3OB0tI/AAAAAAAACf4/qIkQ4vfHN5U/s1600/QTreeTestBlankShot.jpg(QTreeView inserted in QML)!

    I am not able to insert the "TreeView" into the rest of my QML and I can't figure out why.

    If I try to add a property change to x, y, width or height, for example:

    @ TreeView {
    id: myTreeView
    x: 15
    y: 15
    allColumnsShowFocus: true
    }@

    I get error: Invalid property assignment: "x" is a read-only property

    Of course I will post plenty more code if someone thinks they might be able to help.

    The application already uses a QDeclarativeView with an OpenGL backend like so:

    @QGLWidget *glWidget = new QGLWidget(this);
    setViewport(glWidget);
    setViewportUpdateMode(QGraphicsView::FullViewportUpdate);@

    There is of course a bit more code involving setting the FileSystemModel, etc, but I don't believe it is relevant. I am really quite baffled here. Obviously, I need the QTreeView to show within the rest of my QML or there really is no point.

    If anyone could point me to a way to do this, I would very much appreciate it. I'm pretty new to Qt and I readily admit that I sometimes have no idea what is going on "under the hood", especially when it comes to the whole MOC file paradigm.

    Whatever way I can get this done is fine with me. I really thought the plugin (qmlRegisterType) method was the way to go, because I'm using it to create an OpenGL window for animations in a separate part of the app, but, as you can see, it ain't working.

    Thanks for your help!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on 13 Jul 2012, 00:10 last edited by
      #2

      Hi,

      You'll need to wrap the QTreeView in a QGraphicsProxyWidget to use it in a mixed QML scene. The C++ Extensions: QWidgets example at http://doc-snapshot.qt-project.org/4.8/declarative-cppextensions-qwidgets.html gives an example of this technique.

      Regards,
      Michael

      1 Reply Last reply
      0
      • U Offline
        U Offline
        ultramanjones
        wrote on 13 Jul 2012, 17:15 last edited by
        #3

        @mbrasser Thanks for the quick reply! I believe you are correct sir. I am going about implementing that solution now. I will post back with my results.

        Cheers!

        1 Reply Last reply
        0
        • U Offline
          U Offline
          ultramanjones
          wrote on 13 Jul 2012, 23:06 last edited by
          #4

          Ok, I got at least the preliminary workings of this implemented. It still needs all kinds of work to be fully functional, but see "here":http://ultraopengl.blogspot.com/2012/07/qtreeview-in-qtquickqml-implementation.html folks if you are interested in learning more.

          Again. Thanks for the help!

          Share the love

          Cheers!

          1 Reply Last reply
          0

          1/4

          12 Jul 2012, 19:59

          • Login

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