[Solved]How to call userdefined function from StyleSheet?
I want to call my function from Stylesheet attribute .
getUrl() is my function .
Please give your suggestions
[quote author="sweeten" date="1342004010"]I want to call my function from Stylesheet attribute .
You cannot. Sorry.
Give your suggestions[/quote]
Using "please" will get you a long way...
Thank You, Andre for your reply.
Is there any other possiblities to call my function from Stylesheet attribute?
No, style sheets can set properties, but you cannot use values from properties or functions in them.
A (common) workaround for this is using placeholders in your stylesheet and then pre-processing it.
QString styleSheet = ...;
Brain to terminal.
Thank you Andre.
Thank you Lukas for your suggestion.
Another question from my side:
Let's assume i have a button icon, which i assign to the button (stylesheet) like this:
for the hover state of the button, i would like to use the same image, but manipulate it myself like this:
in which the function would add some glowing effect to the image. That would reduce a lot of work to supply hundreds of hover images.
Is this also not possible?
What I do, is using multiple images. I use a separate image for the border, and a transparent image with the icon on top of that. That limits the number of images I need considerably. I only need one common set of base images: normal, disabled, checked/active, normal & hovered, checked & hovered, and one icon image per button.
Again: you can not call functions like you try to do in your example. You're thinking of style sheets in completely the wrong way. They are not like an imparative language, but like a declarative language.
Thanks Andre, that makes it more clear for me. So the only approach to add more dynamic is the pre-parsing mechanism.
That helps yo understand stylesheets more. Thanks again!