Qt/QML学习-TextEdit

QML学习

main.qml

复制代码
import QtQuick 2.15
import QtQuick.Window 2.15

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    Rectangle {
        anchors.centerIn: parent
        width: textEdit.width
        height: textEdit.height
        color: "yellow"
        TextEdit {
            id: textEdit
            anchors.centerIn: parent
            text: "TextEdit"
            color: "red"
            font{
                pointSize: 30
                bold: true
            }
            selectByMouse: true
            selectionColor: "blue"
            cursorDelegate: Canvas {
                width: 4
                onPaint: {
                    var ctx = getContext('2d')
                    ctx.setLineDash([2, 2, 2])
                    ctx.lineWidth = 4
                    ctx.strokeStyle = "#444fff"
                    ctx.lineCap = "round"
                    ctx.beginPath()
                    ctx.moveTo(0, 0)
                    ctx.lineTo(0, height)
                    ctx.stroke();
                }
            }
        }
    }
}

演示

相关推荐
Answer1st5 分钟前
【嵌入式学习】嵌入式原理知识-DMA(九)
学习
时间的拾荒人23 分钟前
Qt 事件机制全解析:从事件处理到事件过滤器
开发语言·qt·面试
传奇开心果编程32 分钟前
【ArkUI进阶练中学】第11课:安全与合规进阶
学习·ui·华为·harmonyos
Mr_Macallon2 小时前
C++回顾(基础)(01)
c语言·开发语言·c++·学习
sunoo-2293 小时前
【ARM嵌入式学习笔记第十天】i.MX6ULL eLCDIF控制器驱动RGB LCD全解析(硬件原理+寄存器配置+裸机代码)
arm开发·笔记·学习
时间的拾荒人3 小时前
Qt 窗口系统详解:从菜单栏到对话框的完整指南
开发语言·qt·面试
kaiyou20264 小时前
用户研究岗秋招,统计分析能力怎么学习和证明?
数据库·python·学习
知识分享小能手4 小时前
C++ 学习教程,从入门到精通,string类和标准模板库 — 完整知识点详解(16)
开发语言·c++·学习
qq_401700414 小时前
Qt 炫酷曲线,图表,2D/3D开源库
开发语言·qt
扶尔魔ocy5 小时前
【qt openGL入门笔记】基础光照
qt·opengl