Detect widget doubleclick
I have tried 2 things:
1. mouseDoubleClickEvent
It worked fine for unclickable widgets like QLabels but did not work for clickable ones like PlainTextEdit or PushButton.
2. eventFilter
Seems to work fine for QLabel as well.
It works for PlainTextEdit but not as intended. It detects a double click only if i click at the very edge of widget (what is like 1 pixel). If I double click the main widget area(where you can put text in) nothing really happens.
Code:
class myEventFilter
: public QObject{
public:
{
if(event
->type
() == QEvent::MouseButtonDblClick) {
qDebug() << "Widget double clicked";
return true;
}
else
return QObject::eventFilter(object,event
);
}
};
Code:
ui->plainTextEdit->installEventFilter(new myEventFilter(this));
Re: Detect widget doubleclick
For the plain text edit, install the even filter in the edit's viewport widget.
Cheers,
_
Re: Detect widget doubleclick
Oh, great, thanks for the advice.