Scale QPainter so that it keeps my drawing coordination
Unsolved
General and Desktop
-
I have a QLabel that I set an image QPixmap to it and I want to draw some points on the image.The image label has
m_imageLabel->setScaledContents(true);
so that when I change the window the point should scale also.
I try to keep the original point coordination rescaling the painter :// Calculate the size keeping ratio image with zoom factor //this is call in qlabel paint event QSize sizeWithRatio(m_imageWidth, m_imageHeight); // original photo size sizeWithRatio.scale(width() - 10, height() - 10, Qt::KeepAspectRatio); qreal resizeRatioH = sizeWithRatio.height() / (qreal)m_imageHeight; qreal resizeRatioW = sizeWithRatio.width() / (qreal)m_imageWidth; QPainter painterImage(this); painterImage.scale(resizeRatioW, resizeRatioH); painterImage.setRenderHint(QPainter::Antialiasing);
What I want is to keep the point in same place if I resize the window