Results 1 to 8 of 8

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

  1. #1
    Join Date
    Feb 2019
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Challenges in migration of Qt 4.8.2 project into Qt 5.7 and above

    Your problem comes from using QDeclarativeItem in a QGraphicsScene.

    While a Qt4 QtQuick Scene is essentially a QGraphicsScene, it is very hacky to then use that quick scene as if it where a normal QGraphicsScene.

    If your only use case for using the declarative engine is to have a model/view access API, I would recommend using standard QGraphicsScene and just doing the model access yourself.

    If you are using the declarative framework for the actual item construction, I would recommend not interacting with the QGraphicsScene from C++. This will then nicely map to using Qt5 QtQuick.

    Now we used QQuickWidget and added it directly in QGraphicsscene
    You would be using the QQuickWidget instead of the QGraphicsView, not as a part of it


    Cheers,
    _

  3. #3
    Join Date
    Feb 2019
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Challenges in migration of Qt 4.8.2 project into Qt 5.7 and above

    Hi anda_skoa,

    If you are using the declarative framework for the actual item construction, I would recommend not interacting with the QGraphicsScene from C++. This will then nicely map to using Qt5 QtQuick.

    Some of the items are created as QGraphicsItem and some are QDeclarativeItem, If we will not use QGraphicsScene, then how will we add QGraphicsItems to the scene?

    You would be using the QQuickWidget instead of the QGraphicsView, not as a part of it

    QGracphicsView and QGraphicsScene is already there and we used QQuickWidget to show the QML items into the scene.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Challenges in migration of Qt 4.8.2 project into Qt 5.7 and above

    Quote Originally Posted by Anjali Srivastava View Post
    Some of the items are created as QGraphicsItem and some are QDeclarativeItem, If we will not use QGraphicsScene, then how will we add QGraphicsItems to the scene?
    What kind if items do you create as graphics items?

    It might be possible to just make custom declarative items and create all items from QML.

    Quote Originally Posted by Anjali Srivastava View Post
    QGracphicsView and QGraphicsScene is already there and we used QQuickWidget to show the QML items into the scene.
    So currently you have a QDeclarativeView as an item in your QGraphicsScene?

    Cheers,
    _

  5. #5
    Join Date
    Feb 2019
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Challenges in migration of Qt 4.8.2 project into Qt 5.7 and above

    What kind if items do you create as graphics items?
    Grids and Ellipses are created as graphics item and in future vendor company will also create some items as graphics Item.

    It might be possible to just make custom declarative items and create all items from QML.
    In Qt 4.8.2 we used QDeclalativeItem to create some objects in QML and added it to QGraphicsScene. But now in Qt 5.7 how will we create it?

    So currently you have a QDeclarativeView as an item in your QGraphicsScene?
    No, We are not using QDeclarativeView. We used QQuickWidget to access Item form QML file and added it to QGraphicsScene.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Challenges in migration of Qt 4.8.2 project into Qt 5.7 and above

    Quote Originally Posted by Anjali Srivastava View Post
    Grids and Ellipses are created as graphics item and in future vendor company will also create some items as graphics Item.
    Should be trivial to create these as custom QDeclarativeItems

    Quote Originally Posted by Anjali Srivastava View Post
    In Qt 4.8.2 we used QDeclalativeItem to create some objects in QML and added it to QGraphicsScene.
    Ah, ok, very hacky.

    If you use a QDeclarativeView instead then you can use the same approach when moving to a QQuickWidget.


    Quote Originally Posted by Anjali Srivastava View Post
    We used QQuickWidget to access Item form QML file and added it to QGraphicsScene.
    Well, that's not possible since Qt5 QQuickItems are not QGraphicsItems.
    QtQuick is rendered with an OpenGL based scene graph.

    As far as I understood your setup you have these options:

    1) Remove the usage of QML

    2) Keep using QGraphicsView and just use QQmlEngine with custom types to create QGraphicItem based objects in QML

    3) Move the Qt4 version to use QDeclarativeView and custom QDeclarativeItem and then port that almost unchanged to QtQuickWidget and custom QQuickPaintedItems.

    Cheers,
    _

  7. #7
    Join Date
    Feb 2019
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Challenges in migration of Qt 4.8.2 project into Qt 5.7 and above

    Quote Originally Posted by anda_skoa View Post
    Should be trivial to create these as custom QDeclarativeItems

    1) Remove the usage of QML

    2) Keep using QGraphicsView and just use QQmlEngine with custom types to create QGraphicItem based objects in QML

    3) Move the Qt4 version to use QDeclarativeView and custom QDeclarativeItem and then port that almost unchanged to QtQuickWidget and custom QQuickPaintedItems.


    _

    Yes I think you are right, If I follow the point two then could you provide any example or link for the same.

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Challenges in migration of Qt 4.8.2 project into Qt 5.7 and above

    The QML engine (in both Qt4 and Qt5) can essentially create instances of any class that is derived from QObject (directly or indirectly).

    So for example if you have a class that derives from QGraphicsObject you should be able to register that with the QML engine's type system and then use in QML like any of the "built-in" types.

    http://doc.qt.io/archives/qt-4.8/qde...mlRegisterType
    http://doc.qt.io/qt-5/qqmlengine.html#qmlRegisterType

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 26th September 2017, 18:49
  2. Migration to QT 5
    By pl01 in forum Newbie
    Replies: 2
    Last Post: 29th April 2013, 13:23
  3. Qt4 migration
    By grsandeep85 in forum Qt Programming
    Replies: 1
    Last Post: 20th August 2009, 08:31
  4. Migration from Qt3 to Qt4
    By mourad in forum Qt Programming
    Replies: 1
    Last Post: 13th May 2008, 20:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.