#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
{
Q_OBJECT
protected:
};
Mouse *mouse = new Mouse();
{
if (event
->type
() == QEvent::MouseButtonPress) {
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event
);
}
}
label->installEventFilter(mouse);
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
class Mouse : public QObject
{
Q_OBJECT
protected:
bool eventFilter(QObject *obj, QEvent *event);
};
Mouse *mouse = new Mouse();
bool Mouse::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress) {
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event);
}
}
QLabel*label=new QLabel();
label->installEventFilter(mouse);
To copy to clipboard, switch view to plain text mode
I wanted to install event filter in Qlabel of my ui application ....I have posted the code above but I am having problem with it...I might be declaring the class in wrong section please help me how to install eventfilter in qlabel for mouseevent handling
Bookmarks