Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt Stylesheet image: Can i add SVG code in "image:" instead of specifying url?
Forum Updated to NodeBB v4.3 + New Features

Qt Stylesheet image: Can i add SVG code in "image:" instead of specifying url?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
9 Posts 3 Posters 3.9k Views 2 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.
  • V Offline
    V Offline
    vdevadass
    wrote on last edited by
    #1

    Can i add SVG code in "image:" instead of specifying url?

    For instance, can i add SVG code for up and down arrows in the stylesheet for QScrollbar rather than specifying an url to the image?

    raven-worxR 1 Reply Last reply
    0
    • V vdevadass

      Can i add SVG code in "image:" instead of specifying url?

      For instance, can i add SVG code for up and down arrows in the stylesheet for QScrollbar rather than specifying an url to the image?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @vdevadass
      IIRC this should work via Qt stylesheets. At least the Qt filesystem is capable of loading such urls, so my guess it also should work within QSS.

      image: url("data:image/png;base64,<base64ImageData>") // replace '<base64ImageData>'
      

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vdevadass
        wrote on last edited by
        #3

        What if i do not want to use base64 image? Can i use SVG instead?

        Reason is i want the image to be scalable

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          Why cant you just use SVG images ?
          Like ":/somefile.svg"
          (it located in qresource)

          1 Reply Last reply
          1
          • V Offline
            V Offline
            vdevadass
            wrote on last edited by
            #5

            i want to eliminate dependency on external resource, hence asking, if we cannot add in the stylesheet i would go for the .svg file.

            mrjjM 1 Reply Last reply
            0
            • V vdevadass

              i want to eliminate dependency on external resource, hence asking, if we cannot add in the stylesheet i would go for the .svg file.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @vdevadass
              Ok but it wont be external if you use resource as its compiled into the .exe (app)
              Anyway, i doubt it will allow the actual SVG code directly. Did not tried it base64 encoded though :)

              1 Reply Last reply
              1
              • V Offline
                V Offline
                vdevadass
                wrote on last edited by
                #7

                Ok, thanks. i'll try that.

                mrjjM 1 Reply Last reply
                0
                • V vdevadass

                  Ok, thanks. i'll try that.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  @vdevadass
                  Note on SVG.
                  Im using SVG for all icons. I discovered that the page "box" ( at least if editing with InkScape)
                  would define the maximum size the icon would become. ( when used with QIcon)
                  So if some of the icons looks fussy, it might be the reason. Simply scale SVG up and resave.

                  1 Reply Last reply
                  1
                  • V Offline
                    V Offline
                    vdevadass
                    wrote on last edited by
                    #9

                    this is my first using SVG, hence i will have a look at it. thanks :)

                    1 Reply Last reply
                    0

                    • Login

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