I don't see any magic in the source code. Qt simply checks the double-click interval time reported by the style and if two subsequent mouse presses are within that interval, it sends a double click event.
ulong doubleClickInterval = static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval());
doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton;
// ...
if (doubleClick) {
mousePressButton = Qt::NoButton;
const QEvent::Type doubleClickType
= frameStrut ?
QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick;
QMouseEvent dblClickEvent
(doubleClickType, localPoint, localPoint, globalPoint,
button, buttons, e->modifiers);
dblClickEvent.setTimestamp(e->timestamp);
QGuiApplication::sendSpontaneousEvent(window, &dblClickEvent);
}
ulong doubleClickInterval = static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval());
doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton;
// ...
if (doubleClick) {
mousePressButton = Qt::NoButton;
const QEvent::Type doubleClickType = frameStrut ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick;
QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint,
button, buttons, e->modifiers);
dblClickEvent.setTimestamp(e->timestamp);
QGuiApplication::sendSpontaneousEvent(window, &dblClickEvent);
}
To copy to clipboard, switch view to plain text mode
Maybe you are getting NonClientAreaMouseButtonDblClick and not MouseButtonDblClick?

Originally Posted by
SteveH
Either way I simply used a QTimer and a few lines of code in a mousePressEvent to get around the problem. Also this way it seperates out single and double presses as exclusive events rather than giving single press or single press + doubleclick events.
So with a single click you first get mouse release event and then mouse press event?
Bookmarks