Porting qt5.5 to qt5.9, qtdeclarative module removing

1.6k Views Asked by At

I have project that written in qt5.5 and below and it contains qtdeclarative module, I am trying to port qt5.5+ but my project using qtdeclarative module that is removed. So I added equivalent as this document says but members are removed or moved to another class,(setAttribute, viewport, setRenderHints, setViewportUpdateMode ) so how can I use those members inside of my MainViewX or for the qt5.9+ Can I use qtdeclarative without changing mycode significantly?

enter image description here

    QQuickView  *MainViewX;//QDeclarativeView    *MainViewX;
    QQmlEngine  *EngineX;//QDeclarativeEngine  *EngineX;
    QQmlContext *ContextX;//QDeclarativeContext *ContextX;


    QString QML_MainWindow;




#include <QQmlPropertyMap> //#include <QDeclarativePropertyMap>

#include <QTranslator>

MainWindow::MainWindow(QApplication *app, QWidget *parent,QTranslator * mtrans) :
    QWidget(parent)
{
    MainViewX    = new QQuickView;//new QDeclarativeView;
    EngineX      = MainViewX->engine();
    ContextX     = MainViewX->rootContext();

    Info = new InfoX(MainViewX);

    QML_MainWindow = "qrc:qml/main.qml";

    MainViewX->setSource(QML_MainWindow);
    MainViewX->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing);

    MainViewX->setAttribute(Qt::WA_OpaquePaintEvent); //Qt::WA_TranslucentBackground
    MainViewX->setAttribute(Qt::WA_NoSystemBackground);
    MainViewX->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
    MainViewX->viewport()->setAttribute(Qt::WA_NoSystemBackground);
    MainViewX->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
2

There are 2 best solutions below

6
On

QtDeclarative has been removed since Qt 5.6. You have to add QT += declarative in your *.pro file and include the header file QtDeclarative/QDeclarativeView.

See the Qt documentation for more info.

0
On

This is not an actual answer but i am removing and using new qt libraries for project. So qtdeclarative problem is no more relevant.