PDA

View Full Version : Detecting mouse clicks outside of widget



init2null
3rd May 2006, 22:01
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.

e8johan
5th May 2006, 07:46
Have you looked into the possability to grab the mouse (search for mouse grabbing for QWidget).

init2null
5th May 2006, 19:16
Thanks! I completely forgot about mouse grabbing. It was a little tricky to use, but it's working correctly now.