(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;
    @
    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



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

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



  • QtK, Yellow is good idea, if only toolbuttons is ywllow :)
    I think it looks so:
    @toolButton->setStyleSheet("focus { background-mage:none; }");@



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



  • Thanks all men above.

    It seems that the code below is the switch of the background-image.
    @
    toolButton->setStyleSheet("focus { background-mage:none; }");
    @

    I had solved the problem.



  • [quote author="Vass" date="1292970873"]QtK, Yellow is good idea, if only toolbuttons is ywllow :)
    I think it looks so:
    @toolButton->setStyleSheet("focus { background-mage:none; }");@[/quote]

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.