当前位置: 首页 > news >正文

Qt/QML学习-ScrollView

QML学习

  • ScrollView例程
  • 视频讲解
  • 代码

main.qml

import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15Window {width: 640height: 480visible: truetitle: qsTr("Hello World")ScrollView {id: scrollViewwidth: 200height: 200anchors.centerIn: parentclip: trueScrollBar.vertical.policy: ScrollBar.AlwaysOnScrollBar.horizontal.policy: ScrollBar.AlwaysOnbackground: Rectangle {color: "yellow"}TextEdit {id: textEditanchors.centerIn: parenttext: "ScrollView + TextEdit"color: "red"font{pointSize: 30bold: true}selectByMouse: trueselectionColor: "blue"cursorDelegate: Canvas {width: 4onPaint: {var ctx = getContext('2d')ctx.setLineDash([2, 2, 2])ctx.lineWidth = 4ctx.strokeStyle = "#444fff"ctx.lineCap = "round"ctx.beginPath()ctx.moveTo(0, 0)ctx.lineTo(0, height)ctx.stroke();}}}}function scrollViewAddText(text) {// 给TextEdit添加文本textEdit.text += text// 调整视图到scrollView底部scrollView.ScrollBar.vertical.position =scrollView.contentHeight>scrollView.height?(scrollView.contentHeight - scrollView.height)/ scrollView.contentHeight: 0}Button {anchors.left: scrollView.rightanchors.top: scrollView.toptext: "添加文本"onClicked: {scrollViewAddText("\n一键三连")}}
}

演示

视频讲解


http://www.mrgr.cn/news/3794.html

相关文章:

  • 5. container_of 宏的定义、作用及手动实现详细解释
  • pyqt 用lamada关联信号 传递参数 循环
  • DNF攻略:护石符文体系辅助详解,VMOS云手机助攻核心玩法!
  • macOS symbol(s) not found for architecture arm64错误原因总结
  • 理解 CSS 层叠、优先级和继承——WEB开发系列15
  • springboot jar是如何启动的
  • select模型实现TCP聊天室
  • 连锁店收银系统源码-线下收银多端视频展示
  • GPT-4o微调功能现已上线
  • Redis十大数据类型
  • 【HTML】弹性盒子 (display: flex) 布局
  • web前端之选项卡的实现、动态添加类名、动态移除类名、动态添加样式、激活、tabBar
  • 南大-ICS2021 PA1~PA2.2 学习笔记记录
  • 计算机毕业设计Python深度学习房价预测 房价可视化 链家爬虫 房源爬虫 房源可视化 卷积神经网络 大数据毕业设计 机器学习 人工智能 AI
  • 如何生成随机数(通过rand函数,srand函数,time函数深入讲解)
  • BaseCTF 高校联合新生赛Week1(web)
  • Open3D mesh 模型切片
  • 小琳AI课堂:AI(人工智能)和AIGC(AI生成内容)的关系
  • Array List集合的基本使用
  • Docker使用教程