Qt5 and QML: How to update QQuickPaintedItem after widget resize?
<p>I'll be very appreciated for help!</p>

<p>i created a custom object, inherited from QQuickPaintedItem and send it to QML application.</p>

<p>It goes well, but there is some issue.</p>

<p>I need to repaint scaled image every time widget changes it's own size. 
But i can't get it how to make it in C++. It call's paint method only once.</p>

<p>Any suggestions?</p>

<p>Source code:
myimage.h</p>

<pre><code>#ifndef MYIMAGE_H
#define MYIMAGE_H

#include &lt;QQuickPaintedItem&gt;
#include &lt;QQuickItem&gt;
#include &lt;QPainter&gt;

class MyImage : public QQuickPaintedItem
   {
    Q_OBJECT

public:
    explicit MyImage(QQuickItem *parent = 0);
    void paint(QPainter* painter) override;

signals:    


public slots:   
    };

#endif // MYIMAGE_H
</code></pre>

<p>myimage.cpp</p>

<pre><code>#include "layerimage.h"

MyImage::MyImage(QQuickItem *parent) : QQuickPaintedItem(parent)
{
    setImplicitWidth(600);
    setImplicitHeight(600);
}

void MyImage::paint(QPainter *painter)
{
    QImage firstImage("e:/image1.png");
    QImage secondImage("e:/image2.png");

    secondImage = secondImage.mirrored(false, true);

    firstImage = firstImage.scaled(width(), height(),Qt::KeepAspectRatio);

    secondImage = secondImage.scaled(width(), height(),Qt::KeepAspectRatio);

    painter-&gt;drawImage(0,0, firstImage);
    painter-&gt;setOpacity(0.5);
    painter-&gt;drawImage(0,0, secondImage);
}
</code></pre>

<p>main.cpp</p>

<pre><code>#include &lt;QApplication&gt;
#include &lt;QQmlApplicationEngine&gt;
#include &lt;QQmlContext&gt;
#include "myimage.h"



int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QQmlApplicationEngine engine;

    qmlRegisterType&lt;MyImage&gt;("CustomImage", 1, 0 , "MyImage");

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    return app.exec();
}
</code></pre>

<p>main.qml</p>

<pre><code>import QtQuick 2.5
import QtQuick.Controls 1.3
import CustomImage 1.0

ApplicationWindow {
    visible: true
    width: 900
    height: 900
    minimumWidth: 900
    minimumHeight: 480
    title: qsTr("Checker")

    Rectangle
    {
        id: image
        color: "transparent"
        border.color: "red"
        anchors
        {
            margins: 20
            centerIn: parent
            fill: parent
        }
        MyImage
        {
            anchors
            {
                centerIn: parent
            }
        }
    }
}
</code></pre>