现象:在使用qml自定义组件时提示错误Invalid component body specification,如图所示:自定义组件的代码如下:原因:Component只能包含一个顶层的Item。代码中Rectangle和Text都是顶层Item。解决办法:把Text放在Rectangle内部。
发表评论