开发者

QML: Simple word wrap with TextEdit element?

I'm just a beginner to QML and I wanted to make a simple example, which contains just one Rectangle with a TextEdit element:

import QtQuick 1.0

Rectangle {
    width: 400; height: 400
    color: "lightblue"

    TextEdit {
        x: 50; y: 100; width: 300; height: 300
        text: "editable text editable text editable text editable text "
        font.family: "Helvetica"; font.pixelSize: 32
    }
}

The idea here is to just have a few lines displayed that the user can change or add. I just would like it to display it as multiple word-w开发者_JS百科rapped lines instead of just on a single line. I don't even need a scrollbar. Since TextEdit does not have a WrapMode property, how can I do this? :-(

Thanks! Nina


TextEdit has a wordWrap property. See http://doc.qt.nokia.com/4.7/qml-textedit.html#wrapMode-prop.

if you add

wrapMode: TextEdit.WordWrap

to the TextEdit component the text is wrapped to multiple lines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜