Hi all
I need to change cursor when my mouse cursor is over rectangle. I tried using eventFilter but my app crash when I try to run it, can you help me with this:
QMouseEvent *mouseEvent
= static_cast<QMouseEvent
*>
( e
);
QPoint pos
= mouseEvent
->pos
();
if(rect.contains(mouseEvent->pos())){
cursor.setShape(Qt::SizeFDiagCursor);}
else{
cursor.setShape(Qt::ArrowCursor);}
setCursor(cursor);
bool MainWindow::eventFilter(QObject *o, QEvent *e){
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>( e );
QPoint pos = mouseEvent->pos();
if(rect.contains(mouseEvent->pos())){
cursor.setShape(Qt::SizeFDiagCursor);}
else{
cursor.setShape(Qt::ArrowCursor);}
setCursor(cursor);
return QMainWindow::eventFilter(o, e);}
To copy to clipboard, switch view to plain text mode
Bookmarks