.png)
예제를 재현하려고 합니다.여기어디에제목페이지.qml구성요소는 두 개를 생성합니다.제목텍스트경우에도 불구하고제목텍스트유형은 별도의 파일(섹션: 구성요소 인스턴스 계층 아래)에 있습니다. Ubuntu SDK에서 새 프로젝트(C++ 플러그인(qmake)이 포함된 QML 앱)을 만들었습니다. 나의Main.qml다음과 같습니다:
import QtQuick 2.4
import Ubuntu.Components 1.2
import ScopeTesting 1.0
MainView {
objectName: "mainView"
applicationName: "scopetesting.username"
width: units.gu(100)
height: units.gu(75)
Item {
property string title
TitleText {
size: 22
anchors.top: parent.top
}
TitleText {
size: 18
anchors.bottom: parent.bottom
}
}
}
그만큼TitleText.qml예는 다음과 같습니다.
import QtQuick 2.4
import Ubuntu.Components 1.2
import ScopeTesting 1.0
Text {
property int size
text: "<b>" + title + "</b>"
font.pixelSize: size
}
내가 얻는 것은 ReferenceError입니다.
...TitleText.qml:7: ReferenceError: 제목이 정의되지 않았습니다.
내가 여기서 무엇을 놓치고 있는 걸까요? 누구든지 도와줄 수 있나요?
답변1
개체는 파일의 루트 개체에 속하지 않는 한 다른 개체의 속성을 직접 사용할 수 없습니다.
property string title
해당 아이디 로 이동 MainView
하거나 아이디를 부여하여 Item
사용합니다 title
.