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();
                }
            }
        }
    }
}

演示

相关推荐
zhangrelay44 分钟前
如何让手机电脑流畅飞起低碳节能性能拉满-软件安装篇-ESR-Extended Support Release-延长支持版-LTS
linux·运维·笔记·学习
岳轩子1 小时前
jvm学习 引入 第一晚
jvm·学习
胡西风_foxww1 小时前
学习python人工智能路径及资源
人工智能·python·学习·路径·资源·书籍·路线
老歌老听老掉牙1 小时前
Python+PyQt5 实现目录文件扫描与导出工具
python·qt·文件扫描
好奇龙猫1 小时前
【大学院-筆記試験練習:线性代数和数据结构(17)】
数据结构·学习·线性代数
承渊政道1 小时前
C++学习之旅【C++拓展学习之反向迭代器实现、计算器实现以及逆波兰表达式】
c语言·开发语言·c++·学习·visual studio
訫悦1 小时前
体验在Qt中简单使用C++20的协程
qt·c++20·协程
xmRao1 小时前
Qt+FFmpeg 实现 PCM 转 WAV
qt·ffmpeg·pcm
爱吃泡芙的小白白1 小时前
使用Cursor来进行连接SSH远程主机中出现的问题(自用)
服务器·学习·ssh·cursor
●VON2 小时前
Flutter for OpenHarmony:基于选择模式状态机与原子批量更新的 TodoList 批量操作子系统实现
学习·flutter·ui·openharmony·von