Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. addResource with QUrl used in <img src> not working in MAC
Forum Updated to NodeBB v4.3 + New Features

addResource with QUrl used in <img src> not working in MAC

Scheduled Pinned Locked Moved Unsolved Qt WebKit
9 Posts 3 Posters 2.5k 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.
  • Z Offline
    Z Offline
    zandarina
    wrote on 28 May 2020, 15:18 last edited by zandarina
    #1

    Hello, I am writing a pdf report in HTML and what I do is to create the image that I want to add in the pdf and I make a unique identifier of it. Then, I use it in html to add the image. In windows it works very well. But I switched to MAC and i found an empty image.

    Captura de pantalla 2020-05-28 a las 17.13.20.png

     createFiguresForPDFReport(qimage1);
    
    		
    //create an unique identifier of the image. It is a trick
    //for not refering to a file. So it is not necessary to write it
    document.addResource(QTextDocument::ImageResource, QUrl("myimage"), qimage1);
    html = html +
    	"<p><img height=150 width=450 src=\"myimage\"/></p>";
    

    Why doesn't mac find the identifier ? I use Xcode and I don't want to use temporary image files to do that. Thank you very much.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 28 May 2020, 18:04 last edited by
      #2

      Hi,

      Where is that image supposed to be located ?

      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
      • Z Offline
        Z Offline
        zandarina
        wrote on 29 May 2020, 06:40 last edited by
        #3

        Thanks for answering. There is not any image file. It is created (slicing a dicom with vtk and converted to qimage. this image is created properly) and embedded in the html document and this document will be used with QPrinter to obtain a pdf. With QUrl what i get is a unique identifier and I make reference in the img tag of html. This works in windows but in mac the reference to the qimage is not considered it.

        J 1 Reply Last reply 29 May 2020, 06:47
        0
        • Z zandarina
          29 May 2020, 06:40

          Thanks for answering. There is not any image file. It is created (slicing a dicom with vtk and converted to qimage. this image is created properly) and embedded in the html document and this document will be used with QPrinter to obtain a pdf. With QUrl what i get is a unique identifier and I make reference in the img tag of html. This works in windows but in mac the reference to the qimage is not considered it.

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 29 May 2020, 06:47 last edited by
          #4

          @zandarina said in addResource with QUrl used in <img src> not working in MAC:

          this image is created properly

          maybe, probably not.

          Do you check if creation was successful ? Permissions and file directories behave slightly differently on MacOS


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 29 May 2020, 08:45 last edited by
            #5

            The key point here, as suggested by @J-Hilk, is: where do you create these images ? Or rather, where do you store them ?

            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
            • Z Offline
              Z Offline
              zandarina
              wrote on 29 May 2020, 11:46 last edited by zandarina
              #6

              It is not a file, it is a screenshot of the render windows and I do it with vtk and the image is fine. yes i saw the image in the render windows. I never put this image in a file. Thanks

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 29 May 2020, 18:06 last edited by
                #7

                Can you set that image in a QLabel and see it properly ?

                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
                • Z Offline
                  Z Offline
                  zandarina
                  wrote on 2 Jun 2020, 11:52 last edited by
                  #8

                  You are right. It was not a qurl issue it was the screenshot for some reason the bounds of the render windows are not obtained with the same size. I have changed this and now i get the image.

                  Thank you very much

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 2 Jun 2020, 19:04 last edited by
                    #9

                    Glad you found out !

                    Since you have it working now, please mark thread as solved using the "Topic Tool" button or the three doted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)

                    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

                    9/9

                    2 Jun 2020, 19:04

                    • Login

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