Important: Please read the Qt Code of Conduct -

Mesh non Visibile

  • Buon Giorno,scrivo perchè ho un problema voglio fare vedere un mia Mesh ma non riesco a visualizzarla e non mi da nessun tipo di errore vi posto i vari file:


    #include <Qt3DQuickExtras/qt3dquickwindow.h>
    #include <Qt3DQuick/QQmlAspectEngine>
    #include <QGuiApplication>
    #include <QtQml>
    int main(int argc, char **argv)
        QGuiApplication app(argc, argv);
        Qt3DExtras::Quick::Qt3DQuickWindow view;
        // Expose the window as a context property so we can set the aspect ratio
        view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view);
        return app.exec();


    import Qt3D.Core 2.0
    import Qt3D.Render 2.0
    import Qt3D.Input 2.0
    import Qt3D.Extras 2.0
    Entity {
        id: sceneRoot
        Camera {
            id: camera
            projectionType: CameraLens.PerspectiveProjection
            fieldOfView: 25
            aspectRatio: _window.width / _window.height
            nearPlane : 0.1
            farPlane : 1000.0
            position: Qt.vector3d( 0, 0.0, 20.0 )
            upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
            viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
        OrbitCameraController {
            camera: camera
        components: [
            RenderSettings {
                activeFrameGraph: ForwardRenderer {
                    clearColor: Qt.rgba(0, 0.5, 1, 1)
                    camera: camera
            InputSettings { }
        PhongMaterial {
            id: carMaterial
        Mesh {
            id: carMesh
            source: "SferaStl.stl"
        Entity {
            id: carEntity
            components: [ carMesh, carMaterial ]

    QT += 3dextras widgets 3dcore 3drender 3dinput 3dquick qml quick 3dquickextras
    CONFIG += c++11
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    SOURCES += main.cpp
    RESOURCES += qml.qrc\
    # Additional import path used to resolve QML modules in Qt Creator's code model
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    DISTFILES += \       
        main.qml \
    SUBDIRS += \

    Il programma si avvia mi appare la finestra ma non si vede la mesh che è posizionata sulla root

  • @Nio74

    Possibile che sia che devo per forza dargli una texture?


Log in to reply