Hi everybody,

I am developping a custom widget, a compass, composed of a background pixmap and a foreground pixmap (the cursor).

My paintEvent code is a s follow :
Qt Code:
  1. QPainter painter(this);
  2.  
  3. painter.drawPixmap(0, 0, *m_pBackground);
  4. painter.rotate(m_dAngle);
  5. painter.drawPixmap(0, 0, *m_pForeground);
To copy to clipboard, switch view to plain text mode 

The problem here is that after being rotated, the foreground pixmap is not centered over the background pixmap center.

I think I must code something like this :
Qt Code:
  1. QPainter painter(this);
  2.  
  3. painter.drawPixmap(0, 0, *m_pBackground);
  4. painter.rotate(m_dAngle);
  5. painter.translate(x, y);
  6. painter.drawPixmap(0, 0, *m_pForeground);
To copy to clipboard, switch view to plain text mode 
but how to determine x and y ?

It would be great if anybody could give me a clue.

Thanks in advance.