Hi everyone,
I have got a problem to change the cursor shape of my widget on a left click in it.
Context (Qt 4.8, win 7):
I have a QGraphicsScene containing a QGraphicsProxyWidget. This proxy hold my widget.
QGraphicsProxyWidget proxy;
MyWidget widget;
proxy.setWidget(aWidget);
scene.addItem(proxy);
QGraphicsScene scene;
QGraphicsProxyWidget proxy;
MyWidget widget;
proxy.setWidget(aWidget);
scene.addItem(proxy);
To copy to clipboard, switch view to plain text mode
In MyWidget class, I have override the function mousepress & mouserelease as :
if(ev->button() == Qt::LeftButton){
setCursor
(QCursor(Qt
::OpenHandCursor));
}
}
}
void MyWidget::mousePressEvent(QMouseEvent *ev){
if(ev->button() == Qt::LeftButton){
setCursor(QCursor(Qt::OpenHandCursor));
}
}
void MyWidget::mouseReleaseEvent(QMouseEvent *ev){
}
To copy to clipboard, switch view to plain text mode
For information, MyWidget override also the repaintEvent
painter.drawPixmap(0,0,pp);
}
void MyWidget::paintEvent(QPaintEvent* p){
QPainter painter(this);
painter.drawPixmap(0,0,pp);
}
To copy to clipboard, switch view to plain text mode
The problem is the mouse cursor only change when I press the left button of the mouse in the widget and I move my mouse out of the widget and go back again in it focus.
I have tested my code by showing MyWidget as a classic window (MyWidget::show()) and the cursor immediately change when I press the left mouse button.
I certainly miss something to add when the widget is in a proxy.
Thanks for your help,
Paolo
Bookmarks