清除textfield黑莓

时间:2013-07-24 09:25:51

标签: qml blackberry-10 blackberry-cascades

如何清除黑莓中的TextField?这是qml:

Container {
                        horizontalAlignment: HorizontalAlignment.Center
                        verticalAlignment: VerticalAlignment.Bottom
                        leftPadding: 75
                        rightPadding: leftPadding
                        bottomPadding: 40

                    TextField {
                        id: tfComment
                        hintText: qsTr("add comment")
                        inputMode: TextFieldInputMode.Text
                        input {
                            submitKey: SubmitKey.Submit
                            onSubmitted: {
                                cppObj.onCommentSubmitClicked(tfComment.text, "");
                                lComment.text = tfComment.text;
                            }
                        }
                    }
                }

Container {
                        horizontalAlignment: HorizontalAlignment.Center
                        verticalAlignment: VerticalAlignment.Bottom
                        bottomPadding: 200
                        leftPadding: 20
                        rightPadding: leftPadding

                       Label {
                           id: lComment
                           verticalAlignment: VerticalAlignment.Bottom
                           horizontalAlignment: HorizontalAlignment.Center
                           text: cppObj.desc
                       }
                    } 

我想清除输入到TextField的数据,以便我有空间评论另一个。我该怎么做?

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:1)

onSubmitted处理程序中尝试此操作:

tfComment.Text = ""