Flickable Wrapped TextEdit: Difference between revisions
Jump to navigation
Jump to search
AutoSpider (talk | contribs) (Add "cleanup" tag) |
|||
Line 1: | Line 1: | ||
{{Cleanup | reason=Auto-imported from ExpressionEngine.}} | |||
[[Category:HowTo]] | [[Category:HowTo]] | ||
[[Category:Learning]] | [[Category:Learning]] |
Revision as of 15:38, 3 March 2015
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine. Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean. |
A method of having a Flickable TextEdit with wrapped text within another Item.
import QtQuick 1.0
FocusScope {
width: 200; height: 200
Rectangle {
property int margins: 20
x: margins; y: margins
width: parent.width - margins*2; height: parent.height - margins*2
border.color: "black"; border.width: 2; radius: 10
color: "#23896363"
Flickable {
id: flick
width: parent.width - 10; height: parent.height;
clip: true
function ensureVisible {
if (contentY >= r.y)
contentY = r.y;
else if (contentY+height <= r.y+r.height)
contentY = r.y+r.height-height;
}
TextEdit {
id: message
x: 5;
width: parent.width; height: parent.height;
wrapMode: "WrapAtWordBoundaryOrAnywhere"
onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
font.pixelSize: 16
}
}
}
}
Related forum thread: http://developer.qt.nokia.com/forums/viewthread/1956/