Results 1 to 3 of 3

Thread: Detecting mouse clicks outside of widget

  1. #1
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Detecting mouse clicks outside of widget

    I'm having a problem properly implementing the interface of a file renaming mechanism in my Qt 4.1-based program. As you can see from the screenshot, it uses a line edit for the new filename, and that works well.

    The problem is that the rename mode must be closed when the user clicks on the window outside the line edit. Normally, focusOut might be enough, but only the image view itself accepts focus.

    From what I've read, QCoreApplication::setEventFilter may be helpful, but I don't know how to use it. I'm also unsure of how to exclude clicks on the line edit.

    Anyway, any advice would be helpful. If anyone is curious about the program, see my sig. The trunk in SVN contains the new file renaming interface.
    Attached Images Attached Images
    ImageRocket - My Qt4-based image editing program
    Project Page / Screenshots / Source

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Detecting mouse clicks outside of widget

    Have you looked into the possability to grab the mouse (search for mouse grabbing for QWidget).

  3. The following user says thank you to e8johan for this useful post:

    init2null (5th May 2006)

  4. #3
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Detecting mouse clicks outside of widget

    Thanks! I completely forgot about mouse grabbing. It was a little tricky to use, but it's working correctly now.
    ImageRocket - My Qt4-based image editing program
    Project Page / Screenshots / Source

Similar Threads

  1. Stacked widget mouse propagation
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 14th November 2008, 17:54
  2. pass mouse event information to another widget
    By Rooster in forum Qt Programming
    Replies: 5
    Last Post: 12th July 2008, 04:23
  3. Replies: 4
    Last Post: 3rd March 2008, 22:15
  4. Replies: 4
    Last Post: 4th February 2008, 06:16
  5. Forwarding mouse events to another widget.
    By yogeshm02 in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2006, 13:25

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.