ApprenticePython
ApprenticePython

Reputation: 187

Is it possible to place a icon above text in a QPushButton (or a QToolButton) with qt style sheets?

#editButton {
    background: url(:/icons/icons/tango/mods/32x32/pencil.png) top center no-repeat;
    height: 50px;
}

I tried multiple ways to place the text underneath my icon, but appears always in the middle of the button (vertically and horizontally). I know I can do that using a QToolButton in the code, but I need to do that in the application style sheet.

Thanks in advance!

Upvotes: 1

Views: 2511

Answers (1)

ApprenticePython
ApprenticePython

Reputation: 187

Solved. This style rule works as I want to:

#editButton {
    border: 2px solid gray;
    border-radius: 4px;
    background: url(:/icons/icons/tango/mods/32x32/pencil.png) top center no-repeat;
    padding-top: 32px;
}

Setting padding-top to 32px is not enough. Border has to be set too.

Upvotes: 7

Related Questions