Solved Porting from Qt4.8 to Qt5.7
-
In Qt4.8 I had a class A that inherited from QDeclarativeItem. I was using a paint() (virtual function of QDeclarativeItem) function where i did all my drawings. And this QDeclarative item was placed on a QGraphicsScene. Now, while porting to Qt5.7 i found that QDeclarativeItem is deprecated. To achieve the same functionality I tried the following things:
- First, I tried inheriting my class from QQuickPaintedItem, which has another paint() function and tried using it. But I discovered that this paint() function was not invoked even once, probably because it requires a Scene graph. Calling update() also didn't invoke it.
Query: Is this understanding of mine correct, that QQuickPaintedItem::paint() requires a Scene graph? If yes, can someone give me an example according to my use case, both pure Qt based and pure qml based approach.
- First, I tried inheriting my class from QQuickPaintedItem, which has another paint() function and tried using it. But I discovered that this paint() function was not invoked even once, probably because it requires a Scene graph. Calling update() also didn't invoke it.
-
@Luckless said in Porting from Qt4.8 to Qt5.7:
Now, while porting to Qt5.7 i found that QDeclarativeItem is deprecated.
QDeclarativeItem was still included in Qt 5.5. You could try porting to Qt 5.5 first, and then decide if you want to go any further.
Note: QQuickItem is completely incompatible with QGraphicsScene.
I was using a paint() (virtual function of QDeclarativeItem) function where i did all my drawings.
What kind of manual painting does Class A do?
-
Due to company requirements, we have to use Qt5.7 only, where I will again face the same problem that I would have faced porting from Qt4.8 to 5.7(i.e. the deprecated QDeclarativeItem.
What kind of manual painting does Class A do?
I am plotting n points (on a position vs time graph). The positions are updated every second. Further zooming & panning is to be provided. And this painting is currently done on a QGraphicsScene.
-
@Luckless said in Porting from Qt4.8 to Qt5.7:
I will again face the same problem that I would have faced porting from Qt4.8 to 5.7(i.e. the deprecated QDeclarativeItem.
You could download the Qt Quick 1 source code and try to build it using Qt 5.7: https://code.qt.io/cgit/qt/qtquick1.git/tree/ If it works, you will be able to use QDeclarativeItem again.
However, I don't know if any changes between Qt 5.5 and Qt 5.7 broke compatibility with QDeclarativeItem.
I am plotting n points (on a position vs time graph). The positions are updated every second. Further zooming & panning is to be provided. And this painting is currently done on a QGraphicsScene.
Good luck.
Due to company requirements, we have to use Qt5.7 only
That's a strange requirement, given that Qt 5.7 reached end-of-life in June 2017...