Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] Qml Canvas loadImage not working
Forum Updated to NodeBB v4.3 + New Features

[Solved] Qml Canvas loadImage not working

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John_T
    wrote on 9 Jun 2014, 12:38 last edited by
    #1

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

    @canvas.loadImage("C:\Users\John_T\Desktop\paint.png")@

    And then:

    @ onImageLoaded:
    {
    if(canvas.isImageError("C:\Users\John_T\Desktop\paint.png"))
    console.log("Image failed to load!")

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

    @

    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?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      John_T
      wrote on 9 Jun 2014, 22:47 last edited by
      #2

      OK, it works now. Paths needed to be something like this:
      file:///C:/Users/John_T/Desktop/something.png
      If only those error messages were a little more helpful.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 10 Jun 2014, 06:25 last edited by
        #3

        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 !

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        1/3

        9 Jun 2014, 12:38

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved