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

演示

相关推荐
知识分享小能手16 分钟前
高等数学学习教程,从入门到精通,定积分 — 知识点全面总结(10)
学习·机器学习·概率论
暗影凋落7 小时前
CMake构建学习笔记-SQLite库的构建
笔记·学习·sqlite
画面无声8 小时前
STM32的SPI通信原理与练习记录
c语言·stm32·单片机·嵌入式硬件·学习
你有哈莫吗9 小时前
CMake构建学习笔记-iconv库的构建
笔记·学习
ctlover10 小时前
Python学习第4日
学习
小弥儿11 小时前
GitHub今日热榜 | 2026-08-01:硬件安全工具与AI教育并行
人工智能·学习·开源·github
秋雨梧桐叶落莳11 小时前
计算器仿写总结
学习·macos·ios·objective-c·cocoa
统计学小王子12 小时前
《数学少年-从正负号到几何原本》(第一章:“刻度之上,零为分界“)--1.2 电梯与账单里的相反数字
学习·初中数学·初中数学科普·数学科普
流云鹤12 小时前
03Java学习day(3)
java·学习
我命由我1234513 小时前
棘轮效应极简理解
经验分享·学习·职场和发展·产品运营·求职招聘·职场发展·学习方法