How can I use Qt3D and traditional QML together?



  • Hi All,

    I want to change the question. How can I edit the main.cpp file to use Qml3d and traditional qml together?

    The main.cpp I'm using for this traditional qml

    #include <QApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
        return app.exec();
    }
    

    This is the main.cpp for qml3d

    #include <Qt3DQuickExtras/qt3dquickwindow.h>
    #include <Qt3DQuick/QQmlAspectEngine>
    #include <QGuiApplication>
    #include <QQmlEngine>
    #include <QQmlContext>
    #include <QQuickView>
    
    int main(int argc, char* argv[])
    {
        QGuiApplication app(argc, argv);
        Qt3DExtras::Quick::Qt3DQuickWindow view;
    
        view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view);
        view.setSource(QUrl("qrc:/main.qml"));
        view.show();
    
        return app.exec();
    }
    
    

    Thanks.



  • Do you want to embed the images into the 3D scene, or do you need a 2D overlay on top of the 3D scene?



  • Hi,
    I want use png and make image animation (rotate,propery animation etc..) I will also do 3D animation with them.



  • Okay. In this case, you need to render your image into a texture and apply the texture to a mesh.



  • Would you show me a simple example of how I should do it?

    Thank you.



  • @aktay Sorry, I don't have the needed Qt3D skills for that :(



  • @Wieland Okay. Thank you for your help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.