Qt Stylesheet image: Can i add SVG code in "image:" instead of specifying url?
-
wrote on 23 Mar 2018, 10:51 last edited by
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?
-
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?
@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>'
-
wrote on 27 Mar 2018, 10:14 last edited by
What if i do not want to use base64 image? Can i use SVG instead?
Reason is i want the image to be scalable
-
Hi
Why cant you just use SVG images ?
Like ":/somefile.svg"
(it located in qresource) -
wrote on 27 Mar 2018, 10:56 last edited by
i want to eliminate dependency on external resource, hence asking, if we cannot add in the stylesheet i would go for the .svg file.
-
i want to eliminate dependency on external resource, hence asking, if we cannot add in the stylesheet i would go for the .svg file.
@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 :) -
wrote on 27 Mar 2018, 11:06 last edited by
Ok, thanks. i'll try that.
-
@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. -
wrote on 27 Mar 2018, 12:50 last edited by
this is my first using SVG, hence i will have a look at it. thanks :)
1/9