Increase QPushButton clickable area vertically on MacOS
-
I'm porting my app on MacOSX and I've noticed the QPushButtons have always a few pixels of non-clickable area on top and bottom. That's fine, until I decide to use a
custom pushbutton class in which I override the paint function and paint the button myself. The rect() function doesn't return the clickable area, but the area of the whole widget (as it should). As a result the button is drawn according to its rect, but it becomes misleading to the user. The non-active padding on top and bottom reacts to Enter and Leave events (I'm using them to repaint the button on mouse hover), but clicking in these areas does not activate the clicked() signal, which results in inconsistent behaviour. Is there any way to remove the padding or get the real clickable area of the widget?
Edit: Actually I've noticed the same bug with ALL of the buttons (even non-inherited). I'm using Qt 6.5 -
I'm porting my app on MacOSX and I've noticed the QPushButtons have always a few pixels of non-clickable area on top and bottom. That's fine, until I decide to use a
custom pushbutton class in which I override the paint function and paint the button myself. The rect() function doesn't return the clickable area, but the area of the whole widget (as it should). As a result the button is drawn according to its rect, but it becomes misleading to the user. The non-active padding on top and bottom reacts to Enter and Leave events (I'm using them to repaint the button on mouse hover), but clicking in these areas does not activate the clicked() signal, which results in inconsistent behaviour. Is there any way to remove the padding or get the real clickable area of the widget?
Edit: Actually I've noticed the same bug with ALL of the buttons (even non-inherited). I'm using Qt 6.5@Hristo-Konstantinov
Try the following:- set vertical sizePolicy to preferred or expanding
or - make your custom button inherit from QAbstractButton
- set vertical sizePolicy to preferred or expanding
-
The lazy solution was to create a global QStyle (e.g. Fusion) and set it in the constructor of the pushbuttons with overridden paint functions.
-