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. QML SVG files displayed incorrectly
QtWS25 Last Chance

QML SVG files displayed incorrectly

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 2 Posters 4.3k Views
  • 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
    ZoltanLutor
    wrote on 23 Jan 2017, 21:20 last edited by
    #1

    Having problem with displaying SVG files properly. Files are displayed ok in Firefox, Chrome, even in IE, but in QML Image I see only black contures...

    More details here

    Item {
         property alias source : originalImage.source
         Image
         { 
             id: originalImage 
             anchors.fill: parent 
             sourceSize.width: parent.width 
             sourceSize.height: parent.height 
             antialiasing: true 
         }
    }
    

    Any workaround idea?

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZoltanLutor
      wrote on 24 Jan 2017, 18:43 last edited by
      #6

      It seems I've found some workaround: if I replace <style> with <style type="text/css"> in SVG file, images are displayed correctly...

      See e.g. extraGrenade-OK.svg attached to original bug report

      1 Reply Last reply
      1
      • D Offline
        D Offline
        dheerendra
        Qt Champions 2022
        wrote on 24 Jan 2017, 08:56 last edited by
        #2

        Try with simple program like this. Just see if it works.
        Rectangle {
        visible: true
        width: 640
        height: 480

        Image {
            source : Qt.resolvedUrl("file:///Users/dheeru/Downloads/Mozilla_Firefox.svg")
        }
        

        }

        This code works perfectly. Which OS and Qt version ?

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        2
        • Z Offline
          Z Offline
          ZoltanLutor
          wrote on 24 Jan 2017, 09:44 last edited by
          #3

          the problem is not what QML code displays SVG files (my example is ok) but how images displayed for certain SVG files. see referenced bug report for problematic files.

          most probably svglib does not support (properly) some svg features...

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dheerendra
            Qt Champions 2022
            wrote on 24 Jan 2017, 09:58 last edited by
            #4

            which SVG file r u trying to load ? Do you have sample to check ?

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            1 Reply Last reply
            3
            • Z Offline
              Z Offline
              ZoltanLutor
              wrote on 24 Jan 2017, 10:18 last edited by
              #5

              please, check 'here' (link) in original post...

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZoltanLutor
                wrote on 24 Jan 2017, 18:43 last edited by
                #6

                It seems I've found some workaround: if I replace <style> with <style type="text/css"> in SVG file, images are displayed correctly...

                See e.g. extraGrenade-OK.svg attached to original bug report

                1 Reply Last reply
                1
                • Z Offline
                  Z Offline
                  ZoltanLutor
                  wrote on 25 Jan 2017, 07:53 last edited by
                  #7

                  Here it is - according to standard: "If a ‘type’ is not provided, the value of ‘contentStyleType’ on the ‘svg’ element shall be used, which in turn defaults to "text/css" [RFC2046]."

                  It seems, default value handling of style element in SVG images is not correct...

                  1 Reply Last reply
                  0

                  1/7

                  23 Jan 2017, 21:20

                  • Login

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