Results 1 to 2 of 2

Thread: Catch click/unclick event on QMainWindow border

  1. #1
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Catch click/unclick event on QMainWindow border

    Is there a way to find out if a mouse key is pressed or released on the border of a QMainWindow? I'm trying to accurately find out when the user has stopped resizing my mainwindow by using the mouse keys to figure out when the user "lets go" of the window.

    I was trying to see if I could detect the mouse button state inside the resize event of my QMainWindow, but everytime I query the button state, its always printing the
    "resizing stopped! Mouse button is released!"
    message.

    Any suggestions?
    Paul

    Here's what I was trying:
    Qt Code:
    1. void
    2. MainWindowDlg::resizeEvent ( QResizeEvent * pEvent )
    3. {
    4. if ( QApplication::mouseButtons() != Qt::NoButton)
    5. {
    6. printf("Resizing and mouse button is still down!\n");
    7. return;
    8. }
    9. else
    10. {
    11. printf("Resizing stopped! Mouse button is released!\n");
    12. return;
    13. }
    14. ...
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Catch click/unclick event on QMainWindow border

    The window border and title bar are managed by the underlying window manager. So, as the docs say, the resizeEvent is triggered when the window has already been resized, that is why you always get the mouse released button.

    Depending on how many platform you must do this, you should think about approaching this in a platform dependent manner.

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.