Important: Please read the Qt Code of Conduct -

[Solved] Qml Canvas loadImage not working

  • I have a Qt Quick app that is trying to load an image (from a local drive) into a Canvas element.


    And then:

    @ onImageLoaded:
    console.log("Image failed to load!")

        var contex = getContext('2d')
        contex.drawImage("C:\Users\John_T\Desktop\paint.png", 0, 0)


    It doesn't work and I get this output:

    QSslSocket: cannot resolve TLSv1_1_client_method
    QSslSocket: cannot resolve TLSv1_2_client_method
    QSslSocket: cannot resolve TLSv1_1_server_method
    QSslSocket: cannot resolve TLSv1_2_server_method
    QSslSocket: cannot resolve SSL_select_next_proto
    QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
    QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
    qml: Image failed to load

    Any ideas?

  • OK, it works now. Paths needed to be something like this:
    If only those error messages were a little more helpful.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    The SSL errors are probably completely unrelated. However the path problem is more a string problem, one backslash means that you are escaping the next character so you are giving something invalid. On windows you would need to use two backslashes if you wanted to keep that notation. But you already found out that you can use the unix notation which is less error prone with Qt :)

    Since you found the solution, can you please update the thread title prepending [solved] so other forum users may know a solution has been found :)

    Happy coding !

Log in to reply