[SOLVED] Round Button Jaggies



  • I am trying to use a round button on a screen with a background image but I am getting jagged edges from the mask. How can I minimise or eliminate these?

    Here is the original button with its clear background, on the screen background.
    https://www.dropbox.com/s/tm3o2hv685ctdmg/Button1.jpg

    When I try to mask out the dark rectangular area around the button, here is what I get.
    https://www.dropbox.com/sh/g8l6lfdd8mxdct4/_PBEhN9hgG#lh:null-Button2.jpg

    Here is the code I used.
    @ QRect rect1 = new QRect(10,10,110,110);
    QRegion
    region1 = new QRegion(*rect1,QRegion::Ellipse);
    ui->pushButton->setMask(*region1);
    @

    The jagged edges around the button are considerable and I'd like to know how to get rid of them.

    BTW, how come the button on the first image (which is on a transparent background) still shades over the rectangular area around the button, and just doesn't let the screen background come through correctly. It seems that the background partially comes through but not entirely.

    Thanks and regards,
    James



  • Hi,
    Might it not be easier to use the stylesheets on the pushButton. There might be "rounding" parameters for the pushButton corners. Increase that and you will get a oval ;-)



  • the "rounding" stylesheet parameter : @border-radius: 20px@ but i think you might also need to set
    @background :rgba(0, 0, 0, 0) ;@ which sets it transparent so you can still see the background image..



  • Thanks All.

    Actually, it was as easy as setting "background: transparent" for the pushbutton in the stylesheet file!

    But, to find the answer is difficult!

    Regards,
    James


Log in to reply
 

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