QML app chrashes after user-triggered drawImage call



  • I have this code:

    @import QtQuick 2.1
    import QtQuick.Controls 1.0

    Rectangle {
    width: 640
    height: 600
    id: win
    Image
    {
    id: img
    source: "../../../../../Windows/winsxs/x86_setup-uxwizard-clientimages_31bf3856ad364e35_6.1.7600.16385_none_48ada01d8ff36e68/background.bmp"
    width:300
    height:300
    }
    Canvas
    {
    anchors.bottom: parent.bottom
    width:300
    height:300
    id: cnv
    onPaint: {
    var ctx = cnv.getContext('2d');
    ctx.drawImage(img, 0,0,300,300);

        }
    }
    Button {
        text: 'Do it'
        anchors.centerIn: parent
        onClicked: {
            cnv.requestPaint();
        }
    }
    

    }@

    drawImage works (though terribly slow) until you request it by requestPaint. Then it just crashes the app. Tested on Windows 7, QT 5.1. Just change Image.source to any available image file.


Log in to reply
 

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