class member is changed by who????
Unsolved
QML and Qt Quick
-
hey guys:
I use a qquickwidget to show qml file. and I want to scale and center the image with QQuickPaintedItem, but I found the member will be changed,do not know why:class CamPipItem : public QQuickPaintedItem { Q_OBJECT ..... private: const QRectF m_finalRect{1,1,150,150}; QImage m_bgImg,m_dispImg; qreal m_finalW,m_finalH; const QSize m_pipRect{152,152}; };
void CamPipItem::paint(QPainter *painter) { auto *img = &m_dispImg; qDebug("w:%d,h:%d",width(),height()); // m_pipRect is changed to random number painter->drawRect(0,0,m_pipRect.width()-1,m_pipRect.height()-1); painter->drawImage(m_finalRect.x(),m_finalRect.y(),*img); }
m_pipRect is a const member, but it's changed:
thanks for the attention. -
Hi,
What if you use standard initialization rather than initializer list at creation time ?