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
{
setupUi(this);
...
...
bRefresh->installEventFilter(this); //is a QPushButton
}
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
setupUi(this);
...
...
bRefresh->installEventFilter(this); //is a QPushButton
}
To copy to clipboard, switch view to plain text mode
#include "ui_mainwindow.h"
class MainWindow
: public QMainWindow,
public Ui
::MainWindow{
Q_OBJECT
public:
~MainWindow();
#include "ui_mainwindow.h"
class MainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent=0);
~MainWindow();
bool eventFilter(QObject *obj, QEvent *event);
To copy to clipboard, switch view to plain text mode
{
{
if (event
->type
() == QEvent::Enter) {
qDebug() << "enter";
} else {
if (event
->type
() == QEvent::Leave) {
qDebug() << "leave";
}
}
return true;
} else {
return QWidget::eventFilter(obj, event
);
}
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (obj == (QObject*)bRefresh)
{
if (event->type() == QEvent::Enter)
{
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
qDebug() << "enter";
} else {
if (event->type() == QEvent::Leave)
{
QApplication::restoreOverrideCursor();
qDebug() << "leave";
}
}
return true;
} else {
return QWidget::eventFilter(obj, event);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks