QML update image

  • Hi,

    I'm fairly new to QML and Qt in general and have encountered my first real problem.

    I'm trying to create a checkbox which has 3 positions.

    @Rectangle {
    width: 300; height: 200
    CheckMark {
    id: a
    width: 15; height: 15
    x: 10; y: 10
    status: CheckMark.Empty;

            onStatusChanged: {
                console.log("changed a");
                b.status = status;
    MouseArea {
        anchors.fill: parent;
        onClicked: { a.checkStatus(); console.log(a.status); }


    The function checkStatus will change the status of the checkbox:

    @void CheckMark::setStatus(const Status &status)
    if (m_status != status)

        emit statusChanged();


    The checkbox itself is drawn by the painter:
    @void CheckMark::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *widget)

    case Full:
        painter->drawImage(QRect(m_x, m_y, m_width, m_height), checkboxFullImg);
    case Empty:
        painter->drawImage(QRect(m_x, m_y, m_width, m_height), checkboxEmptyImg);
    case InBetween:
        painter->drawImage(QRect(m_x, m_y, m_width, m_height), checkboxInBetweenImg);


    The problem is when the checkbox is clicked the status changes, but the image does not refresh.

    What am i missing here?

  • Ah, the image does refresh, however only when I manually change the window size ...

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.