PLY Object Does Not Show

  • I created a .ply file, which I tested with MeshLab, but does not display in Qt:

    int main(int argc, char *argv[])
    QGuiApplication a(argc, argv);
    QUrl data = QUrl::fromLocalFile("/XXX/flyingwedge/flyingwedge.ply");
    qDebug() << data.fileName();
    Qt3DExtras::Qt3DWindow view;
    Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity;
    Qt3DCore::QEntity *flyingwedge = new Qt3DCore::QEntity(rootEntity);
    Qt3DRender::QMaterial *material = new Qt3DExtras::QMetalRoughMaterial(rootEntity);
    Qt3DRender::QMesh *flyingwedgeMesh = new Qt3DRender::QMesh;
    Qt3DCore::QTransform *flyingwedgeTransform = new Qt3DCore::QTransform;
    flyingwedgeTransform->setScale3D(QVector3D(10.0, 10.0, 10.0));
    Qt3DRender::QFrontFace *frontFace = new Qt3DRender::QFrontFace(rootEntity);
    Qt3DRender::QCamera *camera =;
    camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
    camera->setPosition(QVector3D(0, 0, 40.0f));
    camera->setViewCenter(QVector3D(0, 0, 0));
    return a.exec();
    Another program that is identical to this program shows a torus mesh object fine. What am I missing?

  • Lifetime Qt Champion


    You should add which version of Qt you are using and one which platform it is.

    Might be a silly question but are you sure of the path of your .ply file ?

  • @SGaist Hello again.
    Linux Mint, At least version 5.9. It seems to find the file when I debug and I get no error message. Is there a way to determine that the ply file was read?

    The .ply file is:
    format ascii 1.0
    element vertex 5
    property float32 x
    property float32 y
    property float32 z
    element face 5
    property list uint8 int32 vertex_index
    0 0 0
    10 5 0
    10 -5 0
    9 4 2
    9 -4 2
    3 0 4 3
    3 0 3 1
    4 4 2 1 3
    3 0 2 4
    3 0 1 2

    Anything else I can provide. I am at a loss at this point.

  • Update. I suspect that the problem in with the URL. I added:

    QUrl data = QUrl::fromLocalFile("/home/XXX/flyingwedge/flyingwedge.ply");
    qDebug() << data.isValid() << data.toLocalFile() << QFileInfo(data.toLocalFile()).exists() << data.fileName();

    and got:

    true "/home/XXX/flyingwedge/flyingwedge.ply" false "flyingwedge.ply"
    QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined

    Which says the file does not exist. I guess that @SGaist was correct. Any pointer to the correct way to specify the path for the URL will be greatly appreciated.

  • I moved the file up one level and it works. Why I do not know, but I am no longer stymied; I can proceed.

  • Lifetime Qt Champion

    Glad you found a solution and thanks for sharing !

    Happy coding

Log in to reply

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