我照着书上抄了一段代码,编译能通过,运行时报以下错误:
Starting G:\qml_study\build-Bubbleshot-Desktop_Qt_5_3_MinGW_32bit-Release\release\Bubbleshot.exe...
qrc:///main.qml:25: Error: Qt.createQmlObject(): failed to create object:
qrc:///DynamicImage:1:1: module "QtQuick2" is not installed
我用的Qt版本是5.3.1, 以下是报错的代码:
bubbles.childen[i] = Qt.createQmlObject(qmlString, bubbles, "DynamicImage");
在装qt的时候有的勾可能被你去掉了,所以没装上吧。
你可以重装一下勾上吧
var qmlStringBegin="import QtQuick2.2; Image{width:30;height:30;property var died: flase;source: \"res/bubble_";
for(; i<8; i++) {
var qmlString = qmlStringBegin + (i+1) + ".png\";}"
bubbles.childen[i] = Qt.createQmlObject(qmlString, bubbles, "DynamicImage");
}
QtQuick2.2 应该写成QtQuick 2.2,抄都抄错,