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 :
painter.drawPixmap(0, 0, *m_pBackground);
painter.rotate(m_dAngle);
painter.drawPixmap(0, 0, *m_pForeground);
QPainter painter(this);
painter.drawPixmap(0, 0, *m_pBackground);
painter.rotate(m_dAngle);
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 :
painter.drawPixmap(0, 0, *m_pBackground);
painter.rotate(m_dAngle);
painter.translate(x, y);
painter.drawPixmap(0, 0, *m_pForeground);
QPainter painter(this);
painter.drawPixmap(0, 0, *m_pBackground);
painter.rotate(m_dAngle);
painter.translate(x, y);
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.
Bookmarks