Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Increase QPushButton clickable area vertically on MacOS

Increase QPushButton clickable area vertically on MacOS

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 254 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hristo Konstantinov
    wrote on last edited by Hristo Konstantinov
    #1

    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

    M 1 Reply Last reply
    1
    • H Hristo Konstantinov

      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

      M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #2

      @Hristo-Konstantinov
      Try the following:

      • set vertical sizePolicy to preferred or expanding
        or
      • make your custom button inherit from QAbstractButton
      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hristo Konstantinov
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • H Hristo Konstantinov has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved