[Solved] Qt pushButtons background-color



  • The way my program works is, when a button is pressed, it hide() the pressed button, change my Dialog's background-image and show() a previously hidden button.

    The problem is, whenever i show() a button, the button's background-color becomes transparent and a colored border shows up.

    Why is that? Thanks

    Here's an animated image of my problem.

    "http://postimg.org/image/mi6tdx3lv/":http://postimg.org/image/mi6tdx3lv/


  • Moderators

    i assume you use stylesheets? If so please post it.



  • [quote author="raven-worx" date="1381232373"]i assume you use stylesheets? If so please post it.[/quote]

    That's all my button stylesheets uses : background-color: red;

    Here's the rest of the code.

    @void NetstatMap::on_HomeButton_clicked(){
    setStyleSheet("background-image: url(:/mapom.png)");

    ui->HomeButton->hide();
    ui->backButton->show();
    

    }

    void NetstatMap::on_backButton_clicked(){
    setStyleSheet("background-image: url(:/map.png)");

    ui->backButton->hide();
    ui->HomeButton->show();
    

    }
    @


  • Moderators

    setting it this way will set it also for all child widgets.
    Maybe this is what you want:
    @
    setStyleSheet("NetstatMap { background-image: url(:/map.png); }");
    @



  • [quote author="raven-worx" date="1381232611"]setting it this way will set it also for all child widgets.
    Maybe this is what you want:
    @
    setStyleSheet("NetstatMap { background-image: url(:/map.png); }");
    @[/quote]

    It worked, thanks!


Log in to reply
 

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