hi,
how to install eventfilter for getting mouse coordinate from Qlabel.........please provide me detail
{
if(pEv
->type
()==QEvent::MouseButtonDblClick) /* mouse button is doublclicked*/ {
QLabel *lb
=qobject_cast<QLabel
*>
(pObject
);
if(lb)
{
qDebug()<<"dbl clicked"<<evt->x()<<","<<evt->y();
}
}
}
bool MainWindow::eventFilter(QObject *pObject, QEvent *evt)
{
if(pEv->type()==QEvent::MouseButtonDblClick) /* mouse button is doublclicked*/
{
QLabel *lb=qobject_cast<QLabel *>(pObject);
if(lb)
{
QMouseEvent *mEvt=static_cast<QMouseEvent *>(ect);
qDebug()<<"dbl clicked"<<evt->x()<<","<<evt->y();
}
}
}
To copy to clipboard, switch view to plain text mode
and use installEventFilter(obj) to install this event filter
ex:
int main(int argc, char *argv[])
{
MainWindow w;
w.show();
a.installEventFilter(&w);
return a.exec();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
a.installEventFilter(&w);
return a.exec();
}
To copy to clipboard, switch view to plain text mode
hope it helps
bala
Bookmarks