I'm going to develop a game that relies heavily on animation, hit-testing, state changing, creating/moving/destroying many objects.
Two/four/six/eight views with the same scene and tile based map.
So, should I use QML or QGraphicsView?
I'm going to develop a game that relies heavily on animation, hit-testing, state changing, creating/moving/destroying many objects.
Two/four/six/eight views with the same scene and tile based map.
So, should I use QML or QGraphicsView?
Well... strictly speaking QML (or rather QtQuick) is also QGraphicsView so you'll be using Graphics View anyway. If you want multiple views on one scene then as far as I remember you can't use Qt Quick, it's a one-to-one (or one-to-zero) relation only.
Why does it seem that QML is faster? When I use the Qt Demo QML apps, they work very smooth. But when I use graphics view, updating items positions is so slow...
I think using setPos() might be the culprit. Should I subclass QGraphicsSvgItem and use it's paint() to update it's position?
I saw this example and they subclass a QWidget, reimplement paintEvent() and paint an updated QRect to reflect the items position. Would that help with the speed of QGraphicsView?
I guess with QML comes more of javascript...
Most examples I have seen use javascript for function implementation.
While coding in graphicsview, you will be directly using Qt classes. QML also finally converts the code to Qt graphicsview code.
Because QtQuick is fine tuned to some specific use cases.
Because your code is not optimal.But when I use graphics view, updating items positions is so slow...
No, definitely not. That would break the whole architecture.I think using setPos() might be the culprit. Should I subclass QGraphicsSvgItem and use it's paint() to update it's position?
What would make my code optimal? The code I use gets the mouse position increment(from raw input), then sets the item with setPos():Because your code is not optimal.
Qt Code:
QGraphicsSvgItem * redPointer = new QGraphicsSvgItem(QCoreApplication::applicationDirPath().append("/redPointer.svg")); void Widget::mouseCoord(int x, int y){ }To copy to clipboard, switch view to plain text mode
But that gets awfully slow , any pointers on how to optimize?
Fixing the slowest parts of it. What the slowest parts are depends on the use case.
setPos() is not the bottleneck.The code I use gets the mouse position increment(from raw input), then sets the item with setPos():
I'd start by enabling the item cache.But that gets awfully slow , any pointers on how to optimize?
I would also check QGraphicsScene and see what you have set on your ItemIdexMethod. If your scene is highly dynamic and you have BspTreeIndex enabled, it could cause a slow down there.
Bookmarks