PDA

View Full Version : QtQuick can not display the component item



stereoMatching
8th June 2012, 00:18
Qt version : Qt4.8.1
Qt quick verision : 1.1
Compiler : mingw4.4
OS : win7(qt quick for desktop)

I create a qt quick application project to do some experiment.When I try to
compose the other qml as the example show at http://doc.qt.nokia.com/4.7/gettingstartedqml.html
it always give me a blank view.

//button.qml


import QtQuick 1.1

Rectangle {
id: simplebutton
color: "grey"
width: 150; height: 75
}


this could display normally with the default code generated by the qtCreator(except of the file name)


Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));

QmlApplicationViewer viewer;
viewer.setOrientation(QmlApplicationViewer::Screen OrientationAuto);
viewer.setMainQmlFile(QLatin1String("qml/Qt_quick_example_00/button.qml"));
viewer.showExpanded();

return app->exec();
}


When I want to compose the qml, the widget show nothing but blank screen
//fileMenu.qml


// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

Rectangle {
id: fileMenu
color: "blue"
height: 480; width:1000

Row{
anchors.centerIn: parent
spacing: parent.width / 2

button {
id: loadButton
}
}
}



Only change one line on main.cpp


viewer.setMainQmlFile(QLatin1String("qml/Qt_quick_example_00/fileMenu.qml"));


I place both of the qml in the same folder,yet the compiler always complain
"Cannot assign to non-existent property "button"
button {
"
How could I solve it?Thanks

wysota
8th June 2012, 21:45
Name the file "Button.qml" and not "button.qml" and name the type "Button" and not "button". QML is case-sensitive, types have to start with capital letters.