Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Best way to port QWidget+QPixmap app to QML/Scenegraph?
qtsamuli last edited by
I'm sorry if this has been discussed already, in that case please feel free to point me to relevant thread or documentation. I just have not found a clear answer yet.
I have made a game where rendering happens simply by having a full screen QWidget and rendering QPixmaps on the widget with the QWidget's QPainter::drawPixmap. All the bitmaps (let's call them sprites) are loaded from png files. I would like to port this rendering code to QML/QML Scenegraph to take advantage of hardware rendering in Qt 5 (and to make sure my app keeps working in Qt 5), while keeping the rest of the game logic in C++. What would be the neatest way? I would like to do following:
Keep the game logic in C++, including: adding new sprites to screen, removing sprites from screen, and controlling the position (x,y) of the sprites from C++. Also, if possible, I would like to control the scale (x,y) and transparency information of each sprite from C++.
The sprites may change their location in each frame, so I hope the interconnect between C++ and QML Scenegraph would be as fast as possible so that there would not be too much of an overhead from simply moving the sprites around.
I would like to also receive the touch events to C++ so that I could hook them up with the game logic.
Thank you very much for your insight. I want to make my app ready for Qt 5.