UPDATE: See my later post here for the answer(s) to this question. Or at least a start.
Hello everybody. Help! 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:
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...
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:
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.
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!
------------------------------------
UPDATE 2012-07-13:
I received an answer in the Qt Dev Forums. Here's a link.
This looks promising, because I was already thinking I would probably have to wrap the class/object in another object in order to get QDeclarativeView to accept it.
What I did not see until after I posted this yesterday, is that QtCreator is producing a warning when I run the first example above (the one WITH the QTreeView displayed). I don't have it in front of me but it was something along the lines of QDeclarativeView only supports objects derived from QGraphicsObject. QTreeWidget is NOT a QGraphicsObject, it is derived from QWidget.
I'll let you know what I get working.
I know it's a bit odd posting a question like this, but now you can see the sort of process I go through on a daily basis in the world of programming. The eternally nooborn, learning never ends. (did I just coin a word?)
------------------------------------
UPDATE 2012-07-13:
I received an answer in the Qt Dev Forums. Here's a link.
This looks promising, because I was already thinking I would probably have to wrap the class/object in another object in order to get QDeclarativeView to accept it.
What I did not see until after I posted this yesterday, is that QtCreator is producing a warning when I run the first example above (the one WITH the QTreeView displayed). I don't have it in front of me but it was something along the lines of QDeclarativeView only supports objects derived from QGraphicsObject. QTreeWidget is NOT a QGraphicsObject, it is derived from QWidget.
I'll let you know what I get working.
I know it's a bit odd posting a question like this, but now you can see the sort of process I go through on a daily basis in the world of programming. The eternally nooborn, learning never ends. (did I just coin a word?)
No comments:
Post a Comment
Let me know what you think!