Search code examples
qtqtstylesheets

QSS style file vs Designer style


I'm using a png as a QPushButton background. Style Sheet code:

QPushButton
{
    border: none;
    width: 80px;
    height: 80px;
    background-color: transparent;
    border-image: url(":/icons/GitHub-Mark-Light.png");
}

QPushButton:hover
{
    border-image: url(":/icons/GitHub-Mark-Light-Hover.png");
}

QPushButton:pressed
{
    border-image: url(":/icons/GitHub-Mark-Light.png");
}

If I set this code in Qt Designer then the png background is transparent where it needs to be. But when I set the same code in my CSS file png transparency is being lost.
How do I fix this and use my png through CSS?


Solution

  • I don’t know why the style is applied differently in the case of Qt Designer or CSS file, but apparently Qt Designer somehow overrides the parent style (the style of the parent window) in a special way.

    I solved the problem by transferring the style of the parent window to the CSS file too.