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

演示

相关推荐
牵牛老人4 分钟前
Qt技巧(三)编辑框嵌入按钮,系统位数判断,判断某对象是否属于某种类,控件取句柄,支持4K,巧用QEventLoop,QWidget的窗体样式
开发语言·qt
Niu_brave9 分钟前
Python基础知识学习(2)
开发语言·python·学习
sixteenyy32 分钟前
学习笔记(一)
笔记·学习
计算机学姐1 小时前
基于python+django+vue的在线学习资源推送系统
开发语言·vue.js·python·学习·django·pip·web3.py
月夕花晨3742 小时前
C++学习笔记(26)
c++·笔记·学习
向往风的男子2 小时前
【从问题中去学习k8s】k8s中的常见面试题(夯实理论基础)(三十一)
学习·容器·kubernetes
十启树3 小时前
用Qt 对接‌百度语音识别接口
人工智能·qt·百度·语音识别
蜡笔小新星3 小时前
切换淘宝最新镜像源npm
vue.js·经验分享·学习·npm·node.js
zhangrelay3 小时前
Arduino IDE离线配置第三方库文件-ESP32开发板
笔记·学习·持续学习