PDA

View Full Version : Stylesheet is not working for QToolButton



sudhansu
23rd March 2010, 06:44
Hi Every body

I'm tryng to apply stylesheet for both pushbutton and tool button through qss file. Below i've posted the qss file. its working fine for QPushButton. but not working for QtoolButton. Plz help me.





QPushButton
{
image: url(":/resource/Icons/Popup_BTN_N.png");
}

QPushButton:pressed
{
image: url(":/resource/Icons/Popup_BTN_D.png");
}

QPushButton:focused
{
image: url(":/resource/Icons/Popup_BTN_F.png");
}

QPushButton:hover
{
image: url(":/resource/Icons/Popup_BTN_F.png");
}


QToolButton
{
image: url(":/resource/Icons/Contents_Monitor_Close_Icon_N.png");
}


QToolButton:pressed
{
bimage: url(":/resource/Icons/Contents_Monitor_Close_Icon_D.png");
}


QToolButton:focused
{
image: url(":/resource/Icons/Contents_Monitor_Close_Icon_F.png");
}

zgulser
23rd March 2010, 06:48
Hi,

What about QToolButton::indicator?

sudhansu
23rd March 2010, 07:15
Hi,

What about QToolButton::indicator?

Shall i add it like

QToolButton:indicator
{
image: url(":/resource/Icons/Contents_Monitor_Close_Icon_F.png");
}

My need is to change the colors while it is focussing or selected or neutral.

Is above code right???

zgulser
23rd March 2010, 07:32
Yeah I meant you need to add it like you showed.

But if you want to change the background color, use "background-color" property not "image".

sudhansu
23rd March 2010, 09:21
Yeah I meant you need to add it like you showed.

But if you want to change the background color, use "background-color" property not "image".

i did like this. but its not working. i ve some png to apply toolbutton. it should change during different state like, pressed, or hovered.
how to do it??

sudhansu
24th March 2010, 04:36
i did like this. but its not working. i ve some png to apply toolbutton. it should change during different state like, pressed, or hovered.
how to do it??

Hi ALl
I'm still stuck in the problem. Please tell me how to solve it.
Thank you all.

zgulser
24th March 2010, 06:30
Hi,

I guess it'll work now..

QToolButton:pressed{

border: 2px solid #8f8f91;
border-radius: 6px; // not necessary
background-color:red;

}

sudhansu
24th March 2010, 06:50
Hi,

I guess it'll work now..

QToolButton:pressed{

border: 2px solid #8f8f91;
border-radius: 6px; // not necessary
background-color:red;

}

Thank you very much for the reply. But i need to change the background images. I ve different images for mouse hovering or button focused, neutral and selected . How to do it?

zgulser
24th March 2010, 07:24
Brother then just change as the following;

QToolButton:hover
{
border: 2px solid #8f8f91;
border-radius: 6px; // not necessary
image: url("yourimage.jpg");
}

This is for hover. Apply it to other pseudo states by just replacing hover with selected, focused or something.

sudhansu
24th March 2010, 07:52
Brother then just change as the following;

QToolButton:hover
{
border: 2px solid #8f8f91;
border-radius: 6px; // not necessary
image: url("yourimage.jpg");
}

This is for hover. Apply it to other pseudo states by just replacing hover with selected, focused or something.

No its not working this way. I tried like


QToolButton
{
image: url(":/resource/Icons/Contents_Monitor_Close_Icon_N.png");
}


QToolButton:pressed
{
image: url(":/resource/Icons/Contents_Monitor_Close_Icon_D.png");
}


QToolButton:focused
{
image: url(":/resource/Icons/Contents_Monitor_Close_Icon_F.png");
}


QToolButton::indicator
{
image: url(":/resource/Icons/Contents_Monitor_Close_Icon_F.png");
}

zgulser
24th March 2010, 08:30
QToolButton:hover
{
border: 2px solid #8f8f91;
border-radius: 6px; // not necessary
background- image: url("yourimage.jpg");
}

but make sure to run the program. It's not shown in the designer since it's linked in the source.