Important: Please read the Qt Code of Conduct -

Challenges in migration of Qt 4.8.2 project into Qt 5.7 and above

  • Hello,
    • My project requirement is to display some moving objects(images with text) in one area of screen and list of objects needs to be shown in a tree view in another area of the screen, on selection of any object, detail of that object will be shown in other view(line edit, combo box, table) and particular object will be highlighted (selection) in the tree view. With the moving objects, Grids and Ellipse are also needs to be displayed.
    • So we followed layer type architecture like one graphics item on the above of another graphics item and background of each graphics item is transparent so each object is visible.
    • For the above requirements we used Qt 4.8.2 in which model view architecture and Qt graphics frame work is used.
    • To display moving objects, we have created a parent graphics rectangle item and added this into graphics scene.
    • To support model view architecture in graphics view frame work, we used QDeclarativeItem.
    • So now a QGraphicsRect item is the parent of QDeclarativeItem and successfully added in the QGraphicsScene.
    • Now we planned to upgrade to Qt version i.e. Qt 4.8.2 to Qt 5.7 and above.
    • The challenges we are facing is to change the QDeclarativeItem, when we changed it by QQuickItem then objects are not displayed in the scene because QGraphicsRect item cannot be the parent of QQuickItem.
    • We also tried QQuickPaintedItem but the result was same.
    • QQuickView is some how working but our screen is not loading correctly, some xcb warning is coming in the terminal.
    • Now we used QQuickWidget and added it directly in QGraphicsscene but it’s background is not getting transparent so Grid and Ellipse are not visible.
    • The properties and signals of Qml file is also not accessible through QQuickWidget.What will be the best solution???
    • If we will migrate the whole project in Qml then what is the replacement of QGraphicsscene and if we want to add QGraphicsItems in Qml, will it be possible??? Because we have some vendors and they are developing few objects as a QGraphicsItems.

  • Lifetime Qt Champion


    Since you already have everything working with the graphics view framework, the first step would be to just compile and run your application with Qt 5. Note that you should aim to use the most recent version of Qt or an LTS version rather than such an outdated version.

    Can you explain your motivation of changing to QtQuick ?

  • Hi thanks for reply,
    i have GUI application which was made using Qt 4.8. In my GUI applicarion there are some components which are made using Qt as well as QML.
    Since i used QML which came with Qt 4.8 (older version) so i have used QDelarativeitem in our application. when i compile my code with qt 5.7 (my requirement),Then got some errors for QDeclarativeitem because this class is deprecated in Qt 5.7
    As mentioned in this post i tried QQuickItem and QQuickPaintedItem in place of QDeclarativeItem but i was not able to add it in my QgraphicsScene. So i used QQuickWidget.But This widget is not getting transparent and property and signals are not working with this QQuickWidget.

  • Lifetime Qt Champion

    Deprecation is one thing, what error did you get ?

  • The following are the errors:-

    1. Unknown module QDeclarativce.I solved this by writing quick and qml in .pro.
      2.QWidget:No such file or directory.I solved this by adding widget in .pro.
      3.Class QMouseEvent has no member named posF(). I solved it by replacing by localpos().
      4.QQuickWidget:No Such file or directory. For this i have added qquickwidget in my .pro.
      5.QDeclarativeComponent:No such file or directory. I used QQMLComponent.
      6.QDeclarativeEngine:No such file or directory. I replaced it by QQMLEngine.
      7.QDeclarativeItem:No such file or directory. I replaced by QQuickItem and QQuickPaintedItem also.
      8.QtDeclarative: No such file or directory. I replaced by QtQuick.

    The above mentioned are the workaround for errors i got while compiling in Qt 5.7 as per my understanding.

  • Lifetime Qt Champion

    Based on your list, you should be fine for going with 5.12.1

  • you are right that I should go for latest version of Qt but the thing is I will face the same problem because I am migrating from Qt 4.8.2 and these declarative classes are deprecated and my client's requirement is to make application in Qt 5.7.. My problem is how to display the QML item in QGraphics scene or If I use QML scene then how will I place QGraphicsItem on it?

    As explained earlier, in 4.8.2 I used QGraphicsScene and some of my objects are created as QGraphicsItems and I place them in background and foreground of the scene. Some of the objects are created as QDeclarativeItem and I added them in QGraphicsScene. While migration in Qt5.7, I found a workaround to place the QDeclativeItem on scene as I have created QQuickWidget and added it on scene but I am not able to make its background transparent because of that my other GraphicsItems are not visible. What will be the best approach to solve this specific problem?

Log in to reply