December 21, 2010

hisong1988 hisong1988
Lab Rat
72 posts

(Solved)How to disable the background-image in runtime?

 

Hello, everyone.

Now I face the problem.
I set a default image as the background-image of a QToolbutton by using setStyleSheet funtion;

  1. toolButton->setStyleSheet("background-image:url(:/gfx/sy_101.png)");

Now I want to the “turn off “ the image when I click the button. what should I do?

any suggestions?

best regards.
hisong

 Signature 

I am still searching for….

5 replies

December 21, 2010

QtK QtK
Lab Rat
1140 posts

It seems you want to change the background on focus. You can try something like

  1. toolButton->setStyleSheet("focus { background:yellow; }");

December 21, 2010

Vass Vass
Ant Farmer
740 posts

QtK, Yellow is good idea, if only toolbuttons is ywllow :)
I think it looks so:

  1. toolButton->setStyleSheet("focus { background-mage:none; }");

 Signature 


Vasiliy

December 21, 2010

Gerolf Gerolf
Robot Herder
3235 posts

you could do that in one style sheet, then always on click (or focus) the background image is away.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

December 22, 2010

hisong1988 hisong1988
Lab Rat
72 posts

Thanks all men above.

It seems that the code below is the switch of the background-image.

  1. toolButton->setStyleSheet("focus { background-mage:none; }");

I had solved the problem.

 Signature 

I am still searching for….

December 22, 2010

QtK QtK
Lab Rat
1140 posts
Vass wrote:
QtK, Yellow is good idea, if only toolbuttons is ywllow :) I think it looks so: @toolButton->setStyleSheet(“focus { background-mage:none; }”);@

I just wanted to illustrate how to use it. Didn’t exactly mean to use yellow color. :)

 
  ‹‹ spreading false info      [Closed] Modal QMainWindow ? ››

You must log in to post a reply. Not a member yet? Register here!