zoukankan      html  css  js  c++  java
  • QML::Text/TextEdit

      //定义一个文本,写法1
       Text {
           id: t1
           text: qsTr("text")
           font.pixelSize: 50
           font.bold: true
           font.pointSize: 1
       }
    
       //定义一个文本,写法2
       Text {
           id: t2
           text: qsTr("text2")
           font{pixelSize: 30; bold:true}
       }
        
        //定义一个文本
        Text {
             200; height: 200
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            text: "中心"
            color: "red"
        }
    Text {
             200;
            text: "使文本在单行中对于超出部分不要进行省略"
        }
        Text {
             200; elide: Text.ElideLeft;
            text: "使文本在单行中对于超出部分从左边进行省略"
        }
        Text {
             200; elide: Text.ElideMiddle;
            text: "使文本在单行中对于超出部分从中间进行省略"
        }
        Text {
             200; elide: Text.ElideRight;
            text: "使文本在单行中对于超出部分从右边进行省略"
        }
     Text { text: "Hello World!"; font.family: "Helvetica"; font.pointSize: 24; color: "red" }
     Text { text: "<b>Hello</b> <i>World!</i>" }
     Text { x:10; y:100; font.pointSize: 24; text: "Normal" }
     Text { x:10; y:200; font.pointSize: 24; text: "Raised"; style: Text.Raised; styleColor: "#AAAAAA" }
     Text { x:10; y:300; font.pointSize: 24; text: "Outline";style: Text.Outline; styleColor: "red" }
     Text { x:10; y:400; font.pointSize: 24; text: "Sunken"; style: Text.Sunken; styleColor: "#AAAAAA" }
     //超链接
    Text { textFormat: Text.RichText text: "The main website is at <a href="http://qt.nokia.com">Nokia Qt DF</a>." onLinkActivated: console.log(link + " link activated") }

    TextEdit显示一个可编辑的,有格式的文本框。它也可以显示明文和富文本。

        //富文本
        Flickable {//套一个Flickable使其具有滑动效果。
            id: flick
             300; height: 200;
            contentWidth: edit.paintedWidth
            contentHeight: edit.paintedHeight
            clip: true
    
            function ensureVisible(r)
            {
                if (contentX >= r.x)
                    contentX = r.x;
                else if (contentX+width <= r.x+r.width)
                    contentX = r.x+r.width-width;
                if (contentY >= r.y)
                    contentY = r.y;
                else if (contentY+height <= r.y+r.height)
                    contentY = r.y+r.height-height;
            }
    
            TextEdit {
                id: edit
                 flick.width
                height: flick.height
                focus: true
                wrapMode: TextEdit.Wrap //不在一行,多行显示
                onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
            }
        }
  • 相关阅读:
    机会的三种境界
    常用“快”捷键
    心路历程
    中兴笔试及答案
    浅谈oracle中row_number() over()分析函数用法
    IE的F12开发人员工具不显示问题
    1002.A + B Problem II --大数问题
    6470.count --快速矩阵幂
    4151.电影--贪心
    3070.斐波拉契数列--快速幂
  • 原文地址:https://www.cnblogs.com/osbreak/p/12663946.html
Copyright © 2011-2022 走看看