Hardcoding a double click time is not ideal. Use QApplication::doubleClickInterval() to get the correct number of milliseconds.
Also this doesn't really solve the problem of how to ignore the mouse press if there is a double click coming. Basically it's impossible to determine on mouse press if another click is coming, since it obviously hasn't happened yet. However, if a small delay is acceptable, you can do the following:
In your mousePressEvent, start a timer with a timeout of QApplication::doubleClickInterval() + a little bit, where a little bit is some small number of milliseconds as a buffer.
If the user clicks just once, then you can execute whatever action you want when the timer finishes. If you get a mouseDoubleClick before your timer finishes, you can cancel the timer and execute the double click action.
Like I said, the only downside is that there will be about a 400 ms delay when responding to single clicks.
Bookmarks