Nina Nordstrom
Nina Nordstrom

Reputation: 85

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-wrapped 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

Upvotes: 0

Views: 4913

Answers (1)

blakharaz
blakharaz

Reputation: 2590

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.

Upvotes: 2

Related Questions