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. QDialogButtonBox accepts clicks outside the buttons ( but near to them )

QDialogButtonBox accepts clicks outside the buttons ( but near to them )

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 744 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    SajasKK
    wrote on last edited by
    #1

    I am using QDialogButtonBox for having the Ok-Cancel Buttongroup for my dialog. The application that is written is intended to run on both Mac and Windows. The layout of the buttons are coming correctly. But in Mac, even when I click somewhere outside the buttons the event related to the click on the nearest button is getting emitted.

    !http://i.stack.imgur.com/fc0Yr.png(Button Click get accepted when clicked outside the button)!

    When I checked the button boundaries by putting a stylesheet for the QPushButtons the buttons appear to be taking up additional space.

    !http://i.stack.imgur.com/Ij4PJ.png(Button layout after applying style sheet)!

    This is the code:

    @QDialogButtonBox * okCancelButtonBox = new QDialogButtonBox( this );
    mOKButton = new QPushButton( "OK", okCancelButtonBox );
    connect( mOKButton, &QPushButton::clicked, this, &MyDialog::Accept );

    mCancelResetButton = new QPushButton( "Cancel", okCancelButtonBox );
    connect( mCancelResetButton,&QPushButton::clicked, this, &MyDialog::Reject );

    okCancelButtonBox->addButton( mOKButton, QDialogButtonBox::AcceptRole );
    okCancelButtonBox->addButton( mCancelResetButton, QDialogButtonBox::RejectRole );

    dialogLayout->addWidget( okCancelButtonBox );@
    The QDialogButtonBox seems to be taking care of the button layout differences in Windows and Mac automatically. So I don't want to have my own layout to do those changes. Is there any way to avoid this false click events using QDialogButtonBox itself?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      That, it seems, would be a wider problem than just QDialogButtonBox. QDialogButtonBox uses QPushButtons. That would suggest that the same problem should exist for other push buttons. Could you check that? (I don't have a Mac).

      In any case: please file a bugreport.

      As a workaround, perhaps you can use an event filter to manipulate which mouse events are passed through to the button. You might try to filter out clicks on buttons if the clicks are too close to the edge of the button widget. Getting the margin right will take some experimenting of course. If you install this filter on the application itself, and check if the object inherits QPushButton, you may be able to get away with a single filter instead of installing on all buttons individually.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SajasKK
        wrote on last edited by
        #3

        Hi Andre,

        Thanks for the reply. I checked the behaviour with QPushButton. As you pointed out, I was able to see the issue there as well.

        I will raise a bug report.

        Thanks

        1 Reply Last reply
        0

        • Login

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