QML笔记-TextEdit的使用
生活随笔
收集整理的這篇文章主要介紹了
QML笔记-TextEdit的使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
?
?
基本概念
代碼與實例
?
基本概念
一般在TextEdit上套一個Flickable使其具有滑動效果。
再把TextEdit中wrapMode設置為TextEdit.Wrap,使其不在一行。
并且把textFormat設置為TextEdit.RichText,使其能顯示富文本。
?
?
代碼與實例
程序運行截圖如下:
這里富文本框有滑動的效果。
點擊紅色的地方,會打印富文本
代碼如下:
import QtQuick 2.9 import QtQuick.Window 2.2Window {visible: truewidth: 640height: 480title: qsTr("Hello World")Flickable{id : mFlickableIdwidth : textInputId.widthcontentHeight: textInputId.implicitHeightheight: 300clip: trueanchors.centerIn: parentTextEdit{id: textInputIdwidth: 240text: "<strong>Because</strong> we want to use our server locally, we set "+"our domain name \r to be <font color = 'red' >localhost </font>. If we had set it up "+" to\n be something else, we would have to go mess with"+" the host files to resolve whatever we put in here to"+" a recognizable network address. "+"ustleaveinlocalhostitisgoodenoughforourlocalusepurposes."+" Leave the rest to defaults and hit continue. You are then"+" given a choice for the database you want to use"wrapMode: TextEdit.WraptextFormat: TextEdit.RichTextfont.family: "Helvetica"font.pointSize: 20color: "blue"focus: trueonEditingFinished: {console.log("The current text is :"+ text)}}}Rectangle {id : mRectIdwidth: 200height: 100color: "red"anchors.top: mFlickableId.bottomMouseArea{anchors.fill: parentonClicked: {console.log("The new text is :"+textInputId.text)}}} }?
總結
以上是生活随笔為你收集整理的QML笔记-TextEdit的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java工作笔记-Spring Boot
- 下一篇: C++设计模式-命令模式