I'm trying to create a very simple pentagonal custom button in Qt. I'm using PyQt5, but the concepts and style-sheet code should be the same as C++ anyway.
My current code is this:
button.
setFixedSize(QSize(20,
15))x = button.width()
y = button.height()
button = QPushButton()
button.setFixedSize(QSize(20, 15))
button.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
x = button.width()
y = button.height()
points = [QPoint(0, 0), QPoint(x/2, 0), QPoint(x, y/2), QPoint(x/2, y), QPoint(0, y)]
button.setMask(QRegion(QPolygon(points)))
To copy to clipboard, switch view to plain text mode
This almost works great, but unfortunately it ruins the dropshadow effect and the button just ends up looking weird:
Removing the border with
button.setStyleSheet("border-style: none")
button.setStyleSheet("border-style: none")
To copy to clipboard, switch view to plain text mode
doesn't work well because then the button is indistinguishable from the background. What I'm currently using is
button.setStyleSheet("background-color: darkBlue; border-style: none")
button.setStyleSheet("background-color: darkBlue; border-style: none")
To copy to clipboard, switch view to plain text mode
but this makes the button blue (which is not ideal) and it also removes the colour changes when hovering or clicking the button. Ideally, I would like to have
button.setStyleSheet("border-style: outset")
button.setStyleSheet("border-style: outset")
To copy to clipboard, switch view to plain text mode
and keep colour changing functionality you'd expect from a button. However, the above line actually does the same as `border-style: none`, simply removing the border. Is there a way to get an outset border or at least fix the dropshadow effect of the original button?
Bookmarks