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.
Qt Code:
  1. QGraphicsProxyWidget proxy;
  2. MyWidget widget;
  3. proxy.setWidget(aWidget);
  4. scene.addItem(proxy);
To copy to clipboard, switch view to plain text mode 

In MyWidget class, I have override the function mousepress & mouserelease as :

Qt Code:
  1. void MyWidget::mousePressEvent(QMouseEvent *ev){
  2. if(ev->button() == Qt::LeftButton){
  3. setCursor(QCursor(Qt::OpenHandCursor));
  4. }
  5. }
  6.  
  7. void MyWidget::mouseReleaseEvent(QMouseEvent *ev){
  8.  
  9. }
To copy to clipboard, switch view to plain text mode 

For information, MyWidget override also the repaintEvent
Qt Code:
  1. void MyWidget::paintEvent(QPaintEvent* p){
  2. QPainter painter(this);
  3. painter.drawPixmap(0,0,pp);
  4. }
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