QQuickPaintedItem is not advised?
qttester5 last edited by
According to the "docs":http://qt-project.org/doc/qt-5.0/qtquick/qquickpainteditem.html:
"QQuickPaintedItem is meant to make it easier to port old code that is using the QPainter API to the QML Scene Graph API and it should be used only for that purpose."
If we want to do custom drawing in a QML Rectangle, for example, is it not suggested to begin new development using QQuickPaintedItem? What is the alternative? It seems to be the closest technique I have found to do quick hardware accelerated drawing into a portion of a QML scenegraph.
The alternative is the base class and reimplementation of "this method":http://qt-project.org/doc/qt-5.0/qtquick/qquickitem.html#updatePaintNode.
Or use QML Canvas element.
And what if we need to make some kind of Graphic Editor? Like Paint.
We should use QPaint api anyway, right? Even if we reimplement "this":http://qt-project.org/doc/qt-5.0/qtquick/qquickitem.html#updatePaintNode
P.S. Just dont say that you'll advice customGeometry example (plus GL_LINE_STRIP work not so good as triangles on some hardware). If QPainter with OpenGL do the same, why to complicate?
P.P.S And if talk about a few thousand objects (lines, arcs, etc.) overhead for tessellation 3d objects may be more than just draw it in usual way . For example, in 40000 chips example. when enabling openGL mode (window maximized) on nv9600 performance drops almost in 2-3 times.
[quote author="tower120" date="1375198026"]
P.S. Just dont say that you'll advice customGeometry example (plus GL_LINE_STRIP work not so good as triangles on some hardware). If QPainter with OpenGL do the same, why to complicate?[/quote]
Don't worry, I've never looked at any of Qt examples, so there is no danger that I'll mention them :P
As for the second PS: experiment with OpenVG then.
And in general: I don't know. QPainter is not recommended in scenegraph because it introduces another major level of abstraction, possibly hurting performance. But it's not really my area. The only custom painting on scenegraph that I did was to paint my texture on an item subclass - easy and straightforward.
OpenVG - what are you talking about? :)
I just want to draw some vector graphic. Not launch rocket in space.
Why to draw a few lines I have to do God knows what?
You say that QPainter is bad, but show nothing to replace it with.
[quote author="sierdzio" date="1375248780"]
The only custom painting on scenegraph that I did was to paint my texture on an item subclass – easy and straightforward.[/quote]
And you saying me that this is not my case? ;) You draw your texture with QPainter, right?
P.S. If you are not from QT team - there is no offensive to you :)
By the way, I made a small test.
I tried to draw lines a la http://doc-snapshot.qt-project.org/qt5-stable/qtquick/scenegraph-customgeometry.html . But tried to draw them 10000 times. To do this I have to repeat object 10000 times.
And I tried modified https://qt-project.org/doc/qt-5.1/qtopengl/2dpainting.html , which, also, draw at least 10000 lines.
And at least on my hardware QPainter draw at least 2-3 times faster.
Frankly speaking on my nv9600m 1st method just jam.
Look attachments here:
No I am not developing Qt, at least not yet. I plan to do some bug fixing, as Qt Project lacks manpower to fix bugs fast enough.
Since QPainter is faster in your test, go for it ;) As for drawing the texture: I simply had a ready-made PNG file that I needed to be drawn :) So it differs from your needs.
I have referred to OpenVG ("link":http://www.khronos.org/openvg/) because AFAIK Qt supports it, but I have never tried doing anything in it.
Even to use OpenVG I have to use QPainter :)))
P.S. And what for your texture drawing - you could load it through the qml image, and then (if you need to operate it from C++) - load that qml Component. And in this way - you diffidently get rid from QPainter from your code :)))))
I think you misunderstood: I'm not using QPainter for this: "link":https://github.com/sierdzio/closecombatfree/blob/master/src/qmlBase/ccfqmlbasemap.h.
True I could go with pure QML, and it used to be the case in the initial prototyping period, but now I've moved most of the heavy stuff to C++. It's great fun and I've learned a lot: plus I was able to optimise the whole project a lot.
I mean you could ONCE load .qml with Image, and then just use it. Add it to your Item, by setParent. From C++. Look here:
(Look "Loading QML Objects from C++")
And about the topic thread, sierdzio, you were wrong, just like and documentation:
[quote author="tower120" date="1375358722"]And about the topic thread, sierdzio, you were wrong, just like and documentation:
I'm happy to be corrected! Thank you for the link.
@loading QML from C++: I know about this and am using it, too :) In that specific use case I needed to have the whole thing in pure c++ (lots of interactions with other classes). Anyway, we are getting way off the topic :P
[quote author="sierdzio" date="1375359070"]. Anyway, we are getting way off the topic :P[/quote]
You're right, I just want qml Items could be created from C++ :) That would make life much easier.