我对QML很陌生,并且很适合使用C ++。我一直试图通过一些QML示例来尝试学习它。
我正在玩TumblerColumn
控件(来自示例)并且基本上尝试设置模型来设置年份。它类似于:
TumblerColumn {
id: yearColumn
width: characterMetrics.width * 4 + tumbler.delegateTextMargins
model: ListModel {
Component.onCompleted: {
for (var i = 2000; i < 2100; ++i) {
append({value: i.toString()});
}
}
}
onCurrentIndexChanged: tumblerDayColumn.updateModel()
}
现在,我做了一个改变:
TumblerColumn {
id: yearColumn
width: characterMetrics.width * 4 + tumbler.delegateTextMargins
property int startYear: 2000
property int endYear: 3000
model: ListModel {
Component.onCompleted: {
for (var i = startYear; i < endYear; ++i) {
append({value: i.toString()});
}
}
}
onCurrentIndexChanged: tumblerDayColumn.updateModel()
}
这会返回错误:
ReferenceError:未定义startYear
如何为这样的QML元素定义这些只读常量属性。
答案 0 :(得分:3)
java.lang.IllegalArgumentException: Unsupported encoding command ansicpg949
at com.rtfparserkit.parser.standard.StandardRtfParser.processEncoding(StandardRtfParser.java:349)
at com.rtfparserkit.parser.standard.StandardRtfParser.processCommand(StandardRtfParser.java:150)
at com.rtfparserkit.parser.raw.RawRtfParser.handleCommand(RawRtfParser.java:278)
at com.rtfparserkit.parser.raw.RawRtfParser.handleCommand(RawRtfParser.java:241)
at com.rtfparserkit.parser.raw.RawRtfParser.parse(RawRtfParser.java:87)
at com.rtfparserkit.parser.standard.StandardRtfParser.parse(StandardRtfParser.java:50)
at com.rtfparserkit.converter.text.AbstractTextConverter.convert(AbstractTextConverter.java:41)
at com.rtfparserkit.converter.text.StringTextConverter.convert(StringTextConverter.java:34)
at net.sf.mpxj.common.RtfHelper.strip(RtfHelper.java:61)
at net.sf.mpxj.mpp.MPP14Reader.processTaskData(MPP14Reader.java:1513)
at net.sf.mpxj.mpp.MPP14Reader.process(MPP14Reader.java:102)
at net.sf.mpxj.mpp.MPPReader.read(MPPReader.java:136)
at net.sf.mpxj.mpp.MPPReader.read(MPPReader.java:79)
和startYear
不在此范围内。试试这个
endYear
答案 1 :(得分:0)
尝试在result = {'inital_hour': [dict(zip(tuple (query.keys()) ,i)) for i in query.cursor]}
中创建新QtObject
并添加getter和setter
QML