Page 1 of 1

setStyleSheet question

Posted: Fri May 16, 2014 12:30 am
by horsethief
Hello,

I was trying to set the background image of a label using css. I would like to position the image either with the css property "background", or "background-position". My problem is that QT style sheets only seem to accept "top, bottom, left, right and center" for its attributes.

Does anyone know of any tricks to use pixel positioning. EG: background-position: 50px 100px; -- or is this just not possible?

Thanks in advance

Re: setStyleSheet question

Posted: Fri May 16, 2014 1:26 am
by azure_glass
I don't do anything with images in mudlett but...

Maybe you can do "blank" or any color image that have required width and put you image after that image

Re: setStyleSheet question

Posted: Fri May 16, 2014 6:04 am
by Vadi
I haven't tried this. If you can't find any more information on this, I think you'll need to move the label itself to where you want the image to appear, and overlay another on top to do what you want.

Re: setStyleSheet question

Posted: Fri May 16, 2014 7:42 pm
by horsethief
I'm not sure I understand what you mean. Even if I overlaid another no top of the label, wouldn't i still have issues trying to position it where I wanted?

What I'm trying to do is take an image that is 2300 x 1500 pixels, and display it in a 200x200 pixel "minimap" in the corner of my screen (like a minimap in an RTS game like starcraft). I would like to keep the image centered based on my current vmap position, but positioning it with top/bottom/left/right/center just wont get the job done :(

Re: setStyleSheet question

Posted: Fri May 16, 2014 9:45 pm
by Vadi
Oh I see. I didn't realise it was so big and you wanted it to move dynamically. I thought it was static, so you could just move it off to the side and that'd work.

Try asking on the qt-interest mailing list if you can't find any information otherwise (if you don't know how to use a mailing list, I can ask for you).

Re: setStyleSheet question

Posted: Fri May 16, 2014 11:32 pm
by horsethief
I've read a million of them, but I've never actually posted to one. If you wouldn't mind, I would be grateful!

Re: setStyleSheet question

Posted: Sat May 17, 2014 10:00 pm
by Vadi
See http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html, starting from "The relative positioning scheme". Try using the top/left/etc properties to move the window. There's also absolute and relative positioning you can set using a property.