Results 1 to 5 of 5

Thread: Problem with styled QPushButton clickable area

  1. #1
    Join Date
    Jun 2010
    Posts
    26
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Problem with styled QPushButton clickable area

    I have styled my QPushButton using the following style. Inside the border of the button and in the corners there are large areas that are not clickable (about 4 pixels inside the button outline). Using :hover I can see that Qt thinks the mouse is over the button but when I click, the button is not drawn as pressed and there is no clicked signal. It's only when the mouse is close to the centre of the button that I can register a click.

    I have tried experimenting with padding and margins but this hasn't helped. If I remove enough styling so that the widget looks drawn in the native style then the whole button is clickable.

    Qt Code:
    1. color: #000000;
    2. background-color: #ffff00;
    3. }
    4. QPushButton:pressed {
    5. background-color: #4444cc;
    6. }
    7. QPushButton:hover {
    8. color: #cccccc;
    9. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem with styled QPushButton clickable area

    This can't be the only style code for your button.
    Show the rest too.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2010
    Posts
    26
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with styled QPushButton clickable area

    This is the only other styling information I can find, anything else must be set to defaults:

    Qt Code:
    1. QPushButton:focus { background-color: #9494bb; }
    2. QPushButton:disabled {
    3. background-color: #444444;
    4. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Problem with styled QPushButton clickable area

    I get this *exact* problem and was searching the net for an answer. I'm using 4.7.3, and it only manifests for me on macosx, not windows. Basically, the button responds to hover correctly but it seems like there is a clicking dead space all around the button. It seems to affect QPushButton and QComboBox, but maybe others.

    You can take the C++ calculator example, change the Button class to inherit from QPushButton instead of QToolButton, and stick setStyleSheet("background-color:blue;"); in the constructor to reproduce.

  5. #5
    Join Date
    Apr 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Problem with styled QPushButton clickable area

    Anyone solved this problem? I'm seeing the same thing and am looking for a fix. Only seeing the problem on Mac too. Windows clickable area is just fine.

    [UPDATE] Just found this QT open defect:
    http://bugreports.qt.nokia.com/browse/QTBUG-15936

    So it looks like a patch is needed to fix it.
    Last edited by pkissel; 19th July 2011 at 23:55.

Similar Threads

  1. Replies: 3
    Last Post: 8th December 2010, 06:42
  2. Vista-styled warning message dialogs?
    By __m128i in forum Newbie
    Replies: 1
    Last Post: 1st June 2010, 00:15
  3. Scroll Area problem
    By Lodhart in forum Qt Programming
    Replies: 0
    Last Post: 10th October 2009, 14:03
  4. Clickable Regions
    By bbdaffy in forum Qt Programming
    Replies: 6
    Last Post: 22nd July 2009, 12:26
  5. Replies: 0
    Last Post: 8th July 2009, 12:01

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.