C++/Qt5 - Install event filter on UI QPushButton
Qt Creator 3.5.1 (opensource)
Based on Qt 5.5.1 (MSVC 2013, 32 bit)
Windows 7
Hello,
This is the first time I've used the form designer in QtCreator.
So far, so good. I have form that displays what I want.
The problem comes when I try and install an event filter on a QPushButton (bRefresh).
The button does not display, If I place the cursor where the pushbutton should be the eventFilter works.
If I do not install the event filter the button shows, but of course the eventFilter does'nt get called.
What am I doing wrong?
Regards
Code:
{
setupUi(this);
...
...
bRefresh->installEventFilter(this); //is a QPushButton
}
Code:
#include "ui_mainwindow.h"
class MainWindow
: public QMainWindow,
public Ui
::MainWindow{
Q_OBJECT
public:
~MainWindow();
Code:
{
{
if (event
->type
() == QEvent::Enter) {
qDebug() << "enter";
} else {
if (event
->type
() == QEvent::Leave) {
qDebug() << "leave";
}
}
return true;
} else {
return QWidget::eventFilter(obj, event
);
}
}
Re: C++/Qt5 - Install event filter on UI QPushButton
Your event filter is filtering out all events for the button (returning true).
So it will not get the show event or paint events, etc.
Cheers,
_
Re: C++/Qt5 - Install event filter on UI QPushButton
Hello anda_skoa,
Many thanks.
I must spend more time RTFM, than RTFInternet.
Regards