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. Load SVG image with parameters
QtWS25 Last Chance

Load SVG image with parameters

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlsvgimagequick
1 Posts 1 Posters 708 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.
  • S Offline
    S Offline
    SroDev
    wrote on 18 Sept 2022, 14:34 last edited by
    #1

    Hello experts of Qt/QML.
    I have some svg images, example from w3.org:

    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
           viewBox="0 0 110 40" width="100%" height="100%">
    
        <title>Reusable Button</title>
        <desc>Takes parameters from parent document's embedding element.</desc>
    
        <defs>
          <ref id="paramFill" param="color" default="blue"/>
          <ref id="paramText" param="text-label">button</ref>
          <ref id="paramStroke" param="outline" default="navy"/>
        </defs>
    
        <g>
          <rect id="button_rect" x="5" y="5" width="100" height="30" rx="15" ry="15"
            fill="url(#paramFill)" stroke="url(#paramStroke)" />
          <text id="button_label" x="55" y="30" text-anchor="middle"
            font-size="25" fill="black" font-family="Verdana">
            <tref xlink:href="#paramText" />
          </text>
        </g>
    
      </svg>
    

    And i want to know how (if it's possible) to pass the parameters value from qml Image:
    I tried the classic way (web) to do that by url and using qml property on the image but it's not working.

      Image{
            anchors.fill: parent
            property string paramFill: "red"
            property string paramStroke: "blue"
            source:"qrc:/img.svg?paramFill=red&paramStroke=blue"
        }
    

    If anyone can help to achieve this it will save me a lot of hours.

    Thanks by advance and sorry for my bad english

    1 Reply Last reply
    0

    1/1

    18 Sept 2022, 14:34

    • Login

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