Qt Quick 与 QML(三)qml中的基础控件

基础控件

控件名称功能描述示例代码
Rectangle基础绘图控件,创建矩形区域Rectangle {width: 100; height: 100<br> color: "red"; radius: 5}
Text/Label文本显示控件Text {text: "Hello World";<br> font.pixelSize: 24}
Button交互按钮控件Button {text: "提交"; onClicked: console.log("点击")}
CheckBox多选框控件CheckBox {text: "同意协议"; checked: true}
RadioButton单选按钮控件RadioButton {text: "男"; ButtonGroup.group: genderGroup}
TextField单行文本输入框TextField {placeholderText: "用户名";maximumLength: 20}
TextArea多行文本输入框qml<br>TextArea {<br> text: "多行文本...";<br> wrapMode: Text.Wrap<br>}
ComboBox下拉选择框qml<br>ComboBox {<br> model: ["选项1", "选项2"]<br> currentIndex: 0<br>}
Slider滑动条控件qml<br>Slider {<br> from: 0; to: 100;<br> value: 50<br>}
ProgressBar进度条控件qml<br>ProgressBar {<br> value: 75;<br> to: 100<br>}
Image图片显示控件qml<br>Image {<br> source: "logo.png";<br> fillMode: Image.PreserveAspectFit<br>}
Switch开关切换控件qml<br>Switch {<br> checked: true;<br> onCheckedChanged: console.log(checked)<br>}
Delegate系列列表项专用控件qml<br>ListView {<br> delegate: SwitchDelegate {<br> text: "选项"<br> }<br>}

Rectangle

属性及方法说明:

属性/方法类型功能描述示例代码
antialiasingbool控制抗锯齿效果,默认开启(若设置radius则强制开启)Rectangle {antialiasing: false // 关闭抗锯齿}
bordergroup边框属性组,包含颜色和宽度Rectangle {border { color: "red"; width: 2 }}
border.colorcolor设置边框颜色(支持十六进制/RGB/颜色名)border.color: "#FF0000"
border.widthint设置边框宽度(单位为像素,0表示无边框)border.width: 5
colorcolor设置矩形填充色(与gradient互斥,后者优先级更高)color: "lightblue"
gradientGradient定义渐变填充(需配合GradientStop使用)gradient: Gradient {GradientStop { position:0; color:"white" } GradientStop { position:1; color:"black" }}
radiusreal设置圆角半径(可统一设置或分角设置)radius: height/4 // 动态圆角// 或分角设置:topLeftRadius: 10; bottomRightRadius: 5
clipbool控制是否裁剪超出矩形范围的子内容(默认falseclip: true // 启用裁剪
contains(point)method判断点是否在矩形内(参数为point对象)if(rect.contains(Qt.point(10,10))) { ... }

代码示例:

Rectangle {id: rectwidth: 200; height: 100color: "transparent"antialiasing: trueborder { color: "green"; width: 3 }radius: 10gradient: Gradient { //渐变GradientStop { position:0; color:"yellow" }GradientStop { position:1; color:"orange" }}// 方法调用示例Component.onCompleted: console.log(rect.contains(Qt.point(50,50)))}

Text

属性及方法说明:

属性/方法类型功能描述示例代码
advancesize只读属性,返回字符基线间距(Qt 5.10+引入)Text { text: "ABC"; onPainted: console.log(advance) }
antialiasingbool抗锯齿开关(仅Text.NativeRendering渲染类型可禁用)Text { text: "Hi"; antialiasing: false }
baseUrlurl设置相对URL的基础路径(用于富文本中的资源引用)Text { text: "<img src='icon.png'>"; baseUrl: "qrc:/assets" }
clipbool超出文本区域的内容裁剪(默认falseText { width:50; text:"LongText"; clip:true }
colorcolor文本颜色(支持十六进制/RGB/颜色名)Text { text:"Red"; color:"#FF0000" }
contentHeightreal只读属性,返回文本实际高度(含换行)Text { text:"Multi\nLine"; onPainted: console.log(contentHeight) }
elideenum文本省略方式(ElideLeft/Right/MiddleText { width:80; text:"LongText"; elide:Text.ElideRight }
font.boldbool控制字体加粗状态(true启用粗体)Text { text:"Bold"; font.bold:true }
font.capitalizationenum文本大小写转换(支持AllUppercase/SmallCaps等模式)Text { text:"hello"; font.capitalization:Font.AllUppercase }
font.familystring设置字体系列(如"Arial")Text { text:"Custom"; font.family:"Microsoft YaHei" }
font.hintingPreferenceenum字体微调策略(PreferNone/PreferVerticalHinting等)Text { text:"Hint"; font.hintingPreference:Font.PreferFullHinting }
font.italicbool控制斜体显示Text { text:"Italic"; font.italic:true }
font.kerningbool启用/禁用字符间距自动调整(默认trueText { text:"Kerning"; font.kerning:false }
font.letterSpacingreal字符间距(单位像素,可负值)Text { text:"Spaced"; font.letterSpacing:1.5 }
font.pixelSizeint字体像素大小(与pointSize互斥,优先级更高)Text { text:"Size24"; font.pixelSize:24 }
font.pointSizereal字体磅值大小(1磅=1/72英寸)Text { text:"Point12"; font.pointSize:12 }
font.preferShapingbool启用复杂文字排版(如阿拉伯语连字)Text { text:"شكرا"; font.preferShaping:true }
font.strikeoutbool添加删除线Text { text:"Delete"; font.strikeout:true }
font.styleNamestring指定字体变体(如"Light Condensed")Text { text:"Style"; font.styleName:"Semibold Italic" }
font.underlinebool添加下划线Text { text:"Underline"; font.underline:true }
font.weightenum字体粗细(Font.ThinFont.Black共9级)Text { text:"Weight"; font.weight:Font.Bold }
font.wordSpacingreal单词间距(单位像素)Text { text:"Word Space"; font.wordSpacing:5 }
horizontalAlignmentenum水平对齐(Text.AlignLeft/Right/HCenterText { width:200; text:"Center"; horizontalAlignment:Text.AlignHCenter }
lineHeightreal行高倍数(需配合lineHeightMode使用)Text { text:"Line\nHeight"; lineHeight:1.5; lineHeightMode:Text.ProportionalHeight }
renderTypeenum渲染引擎类型(Text.QtRendering/NativeRenderingText { text:"Native"; renderType:Text.NativeRendering }
textFormatenum文本格式(PlainText/RichText/AutoTextText { text:"<b>Bold</b>"; textFormat:Text.RichText }
wrapModeenum换行模式(NoWrap/WordWrap/WrapAnywhereText { width:100; text:"LongWord"; wrapMode:Text.WrapAnywhere }

代码示例:

    Text {text: "测试文本 Text"x: 200; y: 0font {family: "Arial"  //字体italic: true  //斜体letterSpacing: 1.2  //字符间距underline: true  //下划线pixelSize: 16  //字体像素大小weight: Font.Medium //字体粗细}}

Label

 属性及方法说明:

属性类型功能描述示例代码
backgroundItem背景组件(可自定义矩形/图像等)Label { background: Rectangle { color:"lightgray" } }
bottomInsetreal底部内容插入距离(与bottomPadding配合使用)Label { text:"Text"; bottomInset:5 }
implicitBackgroundHeightreal背景隐式高度(只读,根据内容自动计算)Label.onImplicitBackgroundHeightChanged: console.log(implicitBackgroundHeight)
implicitBackgroundWidthreal背景隐式宽度(只读)Label.onImplicitBackgroundWidthChanged: console.log(implicitBackgroundWidth)
leftInsetreal左侧内容插入距离Label { text:"Text"; leftInset:10 }
palettepalette调色板配置(控制颜色主题)Label { palette.windowText:"red" }
rightInsetreal右侧内容插入距离Label { text:"Text"; rightInset:10 }
topInsetreal顶部内容插入距离Label { text:"Text"; topInset:5 }

代码示例:

    Label {x: 400width: 200; height: 100text: "测试文本 Label"leftInset: 15rightInset: 15topInset: 8bottomInset: 8//支持任意Item类型作为背景元素background: Image {source: "file:///home/li/图片/1.png"  //临时方案 正是qrc:/images/1.png 要确保.qrc文件中有对应条目images/1.png//opacity: 0.5}}

Button

核心属性

属性类型功能描述示例代码
textstring按钮显示的文本内容Button { text: "提交" }
enabledbool控制按钮是否可交互(默认true)Button { enabled: false }
autoRepeatbool长按时是否重复触发信号(默认false)Button { autoRepeat: true }
icon.sourceurl按钮图标路径Button { icon.source: "qrc:/save.png" }
backgroundItem自定义背景元素Button { background: Rectangle { color: "blue" } }
font.pixelSizeint文本字体大小Button { font.pixelSize: 16 }
hoverEnabledbool是否启用悬停效果(默认true)Button { hoverEnabled: false }
checkablebool是否支持切换状态(类似开关)Button { checkable: true }
checkedbool当前选中状态(需checkable=true)Button { checked: true }
flatbool是否无边框扁平化样式Button { flat: true }

信号/方法

信号/方法触发条件示例代码
onClicked点击按钮时触发Button { onClicked: console.log("点击") }
onPressed按下鼠标时触发Button { onPressed: status.text="按下" }
onReleased释放鼠标时触发Button { onReleased: status.text="" }
onDoubleClicked双击按钮时触发Button { onDoubleClicked: zoomImage() }
onPressAndHold长按超过800ms时触发Button { onPressAndHold: showMenu() }
toggle()切换checkable按钮状态(编程控制)Button { id: btn; onClicked: btn.toggle() }

代码示例:

    Button {x: 0; y: 110text: "渐变按钮"background: Rectangle {radius: 8color: parent.down ? "#4CAF50" : (parent.hovered ? "#8BC34A" : "#CDDC39")border.color: parent.pressed ? "#2196F3" : "transparent"Behavior on color { ColorAnimation { duration: 100 } }Behavior on border.color { ColorAnimation { duration: 200 } }}contentItem: Text {text: parent.textcolor: "white"font.bold: true}onClicked: console.log("点击事件触发")onPressed: console.log("按下状态")onReleased: console.log("释放状态")}

CheckBox

核心属性

属性类型说明示例代码
checkedbool当前选中状态(二态模式)checked: true // 默认选中
checkStateenumeration三态模式状态(Qt.Unchecked/Checked/PartiallyChecked)checkState: Qt.PartiallyChecked
tristatebool是否启用三态模式(默认false)tristate: true // 启用部分选中状态
textstring显示的文本标签text: "启用功能"
indicatorItem勾选框的视觉元素indicator.width: 20 // 调整勾选框大小
nextCheckStatefunction自定义状态切换逻辑见下方代码示例

关键方法/信号

方法/信号说明触发条件示例代码
toggled(checked)二态模式状态变化信号选中状态改变时触发onToggled: console.log(checked)
clicked()点击事件信号用户点击时触发onClicked: console.log("点击")
checkStateChanged()三态模式状态变化信号三态值改变时触发onCheckStateChanged: console.log(checkState)

代码示例:

    CheckBox {id: chkx: 200; y: 110text: "高级选项"tristate: truecheckState: Qt.PartiallyCheckednextCheckState: function() {if (checkState === Qt.Unchecked)return Qt.PartiallyCheckedelse if (checkState === Qt.PartiallyChecked)return Qt.Checkedelsereturn Qt.Unchecked}onCheckStateChanged: {console.log("当前状态:",checkState === Qt.Unchecked ? "未选中" :checkState === Qt.Checked ? "全选" : "部分选中")}}

RadioButton

核心属性

属性类型说明示例代码
checkedbool当前选中状态checked: true // 默认选中
textstring显示文本标签text: "选项A"
exclusiveGroupExclusiveGroup互斥分组对象exclusiveGroup: tabGroup
indicatorItem单选按钮的视觉元素indicator.width: 20
autoExclusivebool是否自动互斥(默认true)autoExclusive: false // 禁用自动互斥

方法/信号

方法/信号说明示例代码
clicked()点击事件信号onClicked: console.log("选中状态:", checked)
toggled(checked)状态变化信号onToggled: label.text = checked ? "已选" : "未选"

代码示例:

// 互斥分组演示ButtonGroup {id: radioGroupexclusive: true  // 默认true可不写onCheckedButtonChanged: {console.log("当前选择:", checkedButton.text)}}RadioButton {id: radio1x: 400; y: 110text: "选项A"ButtonGroup.group: radioGroup  // 分组控制onClicked: if(checked) text = "选项A(已选)"  // 点击信号}RadioButton {x: 400; y: 150text: "选项B"ButtonGroup.group: radioGrouponCheckedChanged: {  // 状态变化信号if(checked){ console.log("选项B"); radio1.text = "选项A"}}}

TextField

核心属性,方法,信号

类别属性/方法说明示例
核心属性text存储当前文本内容TextField { text: "默认文本" }
placeholderText空白时的提示文字placeholderText: "请输入用户名"
echoMode文本显示模式(密码/普通)echoMode: TextInput.Password
外观控制font.pixelSize字体大小font { pixelSize: 16 }
color文本颜色color: "#333333"
background自定义背景样式background: Rectangle { radius: 5 }
输入限制maximumLength最大输入长度maximumLength: 10
validator输入验证器validator: IntValidator { top: 100 }
inputMask输入格式掩码inputMask: "999.999.999"
交互控制readOnly只读模式readOnly: true
selectByMouse允许鼠标选择文本selectByMouse: true
信号onTextChanged文本变化时触发onTextChanged: console.log(text)
onAccepted按下回车时触发onAccepted: submit()
方法clear()清空文本button.onClicked: textField.clear()
selectAll()全选文本onFocusChanged: if(focus) selectAll()
copy()/paste()剪贴板操作onDoubleClicked: copy()

代码示例

    TextField {id: demoFieldwidth: 200x: 0; y: 210placeholderText: "输入数字(1-100)"validator: IntValidator { bottom: 1; top: 100 }onAccepted: console.log("提交:", text)background: Rectangle {border.color: demoField.focus ? "blue" : "gray"radius: 5}}

‌TextArea‌

核心属性,方法,信号

类别属性/方法类型/返回值说明示例
基础属性textstring存储的文本内容text: "默认内容"
placeholderTextstring空白时的灰色提示文本placeholderText: "输入描述..."
textFormatenum (AutoText/RichText/PlainText)文本格式(支持富文本)textFormat: TextEdit.RichText
外观控制fontgroup字体属性(family/pixelSize等)font { family: "Arial"; pixelSize: 14 }
colorcolor文本颜色color: "#333"
backgroundItem自定义背景项background: Rectangle { radius: 5 }
滚动与布局wrapModeenum (NoWrap/WordWrap)换行模式wrapMode: TextArea.WordWrap
contentWidth/contentHeightreal文本内容实际尺寸width: Math.max(200, contentWidth)
flickable (附属属性)Flickable滚动容器关联属性ScrollView { TextArea { ... } }
交互控制readOnlybool只读模式readOnly: true
selectByMousebool允许鼠标选择文本selectByMouse: true
cursorPositionint光标位置onClicked: cursorPosition =
信号onTextChangedsignal文本变化时触发onTextChanged: console.log(text)
onLinkActivatedsignal(link)点击富文本链接时触发onLinkActivated: Qt.openUrlExternally(link)
方法copy()void复制选中文本button.onClicked: textArea.copy()
paste()void粘贴剪贴板内容onPressed: paste()
selectAll()void全选文本onFocusChanged: selectAll()
deselect()void取消选择onEditingFinished: deselect()

代码示例:

    TextArea {id: areax: 200; y: 210placeholderText: "支持富文本+自动滚动"textFormat: TextEdit.RichTextwrapMode: TextArea.WrapselectByMouse: truebackground: Rectangle {border.color: area.activeFocus ? "blue" : "gray"radius: 5}onLinkActivated: Qt.openUrlExternally(link)}

ComboBox

核心属性,方法,信号

类别属性/方法类型/返回值说明示例
核心属性modelvariant数据模型(数组/ListModel/整数)model: ["A", "B", "C"]
currentIndexint当前选中项索引(-1表示未选中)currentIndex: 1
currentTextstring当前选中项文本onActivated: console.log(currentText)
textRolestring指定模型中的文本角色名(需与模型角色严格匹配)textRole: "text"
交互控制editablebool是否允许编辑输入editable: true
displayTextstring控件显示文本(可自定义格式)displayText: "已选: " + currentText
popupPopup弹出窗口控制属性popup.width: 300
外观定制delegateComponent自定义选项项样式见下方完整示例
indicatorComponent下拉箭头图标indicator: Image { source: "arrow.png" }
backgroundComponent背景样式background: Rectangle { radius: 5 }
信号onActivated(int index)signal选项被选中时触发onActivated: console.log(index)
onAccepted()signal编辑模式下回车确认时触发onAccepted: addItem(editText)
方法find(string text)int查找文本对应的索引find("Apple")
textAt(int index)string获取指定索引的文本textAt(0) // 返回"A"
selectAll()void全选编辑框文本onEditingFinished: selectAll()

代码示例:

    ComboBox {id: combowidth: 200x: 400; y: 210editable: truetextRole: "text"model: ListModel {ListElement { text: "Apple"; color: "red" }ListElement { text: "Banana"; color: "yellow" }}delegate: ItemDelegate {width: parent.widthcontentItem: Text {text: model.textcolor: model.colorfont.bold: combo.currentIndex === index}}onAccepted: if (find(editText) === -1) model.append({text: editText})}

Slider

核心属性,方法,信号

类别属性/方法类型/返回值说明示例
核心属性fromreal滑块最小值 (默认0.0)from: -100
toreal滑块最大值 (默认1.0)to: 200
valuereal当前值 (介于from/to之间)value: 50
stepSizereal步长 (0表示连续滑动)stepSize: 5
orientationenum方向 (Qt.Horizontal/Qt.Vertical)orientation: Qt.Vertical
交互控制livebool拖动时是否实时更新value (默认true)live: false
snapModeenum吸附模式 (Slider.NoSnap/SnapOnRelease/SnapAlways)snapMode: Slider.SnapAlways
pressedbool只读,表示滑块是否被按下onPressedChanged: console.log(pressed)
positionreal只读,逻辑位置 (0.0-1.0)Text { text: (position*100).toFixed(0) + "%" }
样式属性backgroundComponent滑槽背景组件见下方自定义示例
handleComponent滑块手柄组件见下方自定义示例
方法increase()void按stepSize增加valueButton { onClicked: slider.increase() }
decrease()void按stepSize减少valueButton { onClicked: slider.decrease() }
valueAt(real pos)real根据位置比例返回对应值slider.valueAt(0.5) 返回中间值
信号moved()-滑块位置改变时触发onMoved: console.log("滑块移动中")
valueChanged()-value属性改变时触发onValueChanged: model.rotation = value

未完待续。。。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/pingmian/85188.shtml
繁体地址,请注明出处:http://hk.pswp.cn/pingmian/85188.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Redis实现消息队列全解析:从基础到高级应用实战

目录 一、Redis作为消息队列的优势与局限 1.1 核心优势 1.2 适用场景 1.3 局限性及解决方案 二、Redis消息队列实现方案对比 三、List实现基础消息队列 3.1 生产者实现原理 3.2 消费者实现原理 3.3 可靠性增强&#xff1a;ACK机制 四、Pub/Sub实现发布订阅 4.1 消息发…

Windows应用商店中的国学启蒙教育应用

国学启蒙是中国传统文化教育的重要组成部分&#xff0c;主要以经典诵读、传统礼仪、历史故事等内容为载体&#xff0c;向儿童传递中华文化的核心价值观。帮助孩子建立文化认同感&#xff0c;培养良好的道德观念和行为习惯。通过学习古代圣贤的言行&#xff0c;儿童可以初步理解…

安科瑞UL认证ADL3000-E/C导轨表:工商业储能领域的智能之选

一、产品简介 ADL3000-E/C是安科瑞针对电力系统、工矿企业、公用设施的电力监控及能耗统计、管理需求而精心设计的一款智能仪表。该电能表具有精度高、体积小、安装方便等显著优点&#xff0c;为工商业储能系统的智能化管理提供了强有力的技术支持。 功能特性 测量与计量功能…

条件向量运算与三元表达式

在工程计算和数学建模中&#xff0c;我们经常需要根据条件动态选择不同的向量运算方式。这种需求在动力学系统、控制理论和计算机图形学中尤为常见。本文将探讨如何通过 Python 的三元表达式结合 SymPy 符号计算库&#xff0c;实现条件向量运算的高效解决方案。 我们从定义两…

文档开发组件Aspose旗下热门产品优势及应用场景介绍

✨Aspose 是什么&#xff1f; Aspose 是全球领先的文档处理组件厂商&#xff0c;主打一个字&#xff1a;全。 &#x1f4cc; 支持超 100 种文档/图像格式 &#x1f4cc; 覆盖 Word、Excel、PDF、PPT、OCR、BarCode、Email 等模块 &#x1f4cc; 支持 .NET、Java、Python、C、N…

龙虎榜——20250618

上证指数缩量长下影小阳线&#xff0c;个股下跌超3300只&#xff0c;总体护盘的板块表现相对更好。 深证指数缩量收小阳线&#xff0c;横盘震荡已有4天&#xff0c;等待方向选择。 2025年6月18日龙虎榜行业方向分析 1. 半导体 代表标的&#xff1a;沪电股份&#xff08;高阶P…

layui和vue父子级页面及操作

最近在老项目里面添加一些页面&#xff0c;项目太老只能在原有的项目基础和插件上添加代码 html //表格 <table id"dataTable"><thead><tr><th>序号</th><th>名称</th><th></th></tr></th…

Houdini 节点使用方法

Houdini 的节点系统是其程序化建模和特效制作的核心功能之一&#xff0c;通过节点网络实现程序化建模、特效制作、动力学模拟等复杂任务。掌握节点使用方法是高效创作的关键&#xff0c;以下是围绕用户需求的 全面、深入且结构化 的节点使用指南 一、节点基础操作 1. 创建与连…

license授权文件说明

license管理 1.使用场景 系统将自动检测license信息是否过期 - license过去前一个月&#xff0c;会显示warning&#xff1a;license file will expire in 30 days - 当license过去&#xff0c;会显示license file expired#注意 1. 数据库重启时才会启动 License 授权期限校验…

C++11中alignof和alignas的入门到精通指南

文章目录 一、引言二、内存对齐的概念和作用2.1 什么是内存对齐2.2 内存对齐的优势 三、alignof运算符3.1 定义和作用3.2 语法规则3.3 使用示例3.4 注意事项 四、alignas说明符4.1 定义和作用4.2 语法规则4.3 使用示例4.4 注意事项 五、alignof和alignas的结合使用六、实际应用…

防爆+高性能!ABB 防爆伺服电机HY系列守护安全生产

在石油、化工、火工等高风险行业中&#xff0c;如何在易燃易爆环境中确保设备安全稳定运行&#xff0c;同时兼顾高性能&#xff1f;ABB防爆伺服电机HY系列给出了完美答案&#xff01; 专为爆炸性环境设计&#xff0c;安全与性能兼得 ABB HY系列基于先进的HDS伺服平台打造&…

洪千武—华为海外HRBP

我的个人介绍 辰熙咨询创始人&CEO 2005年入职华为人力资源管理部 华为海外首批HRBP推动者、华为TUP股权激励实战顾问 华为IBM项目组成员、华为海外代表处AT成员 著有《OKR管理法则》、《力出一孔》 2005年以HR英文专才&#xff0c;从香港著名咨询公司被猎聘到华为人力…

测试:网络协议超级详解

💖亲爱的技术爱好者们,热烈欢迎来到 Kant2048 的博客!我是 Thomas Kant,很开心能在CSDN上与你们相遇~💖 本博客的精华专栏: 【自动化测试】 【测试经验】 【人工智能】 【Python】 </

游戏技能编辑器界面优化设计

界面布局重构 详细界面布局 ---------------------------------------------------------- | 顶部工具栏 [保存] [加载] [撤销] [重做] [测试] [设置] | --------------------------------------------------------- | 资源管理 | | 属性编…

【java中使用stream处理list数据提取其中的某个字段,并由List<String>转为List<Long>】

你当前的代码是这样的&#xff1a; List<String> gongkuangIds gongkuangBoundList.stream().filter(obj -> obj.getBoundValue() ! null).map(PlanSchemeProductionBoundInfo::getBoundValue).distinct().collect(Collectors.toList());这段代码从 gongkuangBoundL…

《前端面试题:JS数组去重》

JavaScript数组去重终极指南&#xff1a;从基础到高级的多种方法&#xff08;附面试题解析&#xff09; 在前端开发中&#xff0c;数组去重是JavaScript中最常见的需求之一。本文将全面解析8种数组去重方法&#xff0c;包括基础实现、ES6新特性、性能优化等&#xff0c;并附上…

基于51单片机的智能小车:按键调速、障碍跟踪、红外循迹与数码管显示(一个合格的单片机课设)

引言 在嵌入式系统领域&#xff0c;51单片机因其简单易用、成本低廉的特点&#xff0c;一直是入门学习的理想平台。今天我将分享一个基于51单片机的多功能智能小车项目&#xff0c;它集成了按键PWM调速、障碍物跟踪、红外循迹和数码管显示四大功能。这个项目不仅涵盖了嵌入式开…

Java异常处理(try-catch-finally):像医生一样处理程序的“感冒”

&#x1f525;「炎码工坊」技术弹药已装填&#xff01; 点击关注 → 解锁工业级干货【工具实测|项目避坑|源码燃烧指南】 一、从一个真实问题开始&#xff1a;为什么需要异常处理&#xff1f; 假设你正在开发一个文件读取工具&#xff0c;用户输入文件名后&#xff0c;程序会读…

PostgreSQL 数据库故障与性能高效实时监测技术深度解析

关键词&#xff1a; postgresql 故障与性能监控 &#x1f4d1; 文章目录 1. 引言与监控重要性 2. PostgreSQL监控体系架构 3. 故障监控核心技术 4. 性能监控关键指标 5. 实时监测技术实现 6. 监控工具选型与部署 7. 故障预警与自动化响应 8. 性能调优监控策略 9. 最佳…

logrotate 踩坑

我的logrotate配置&#xff0c;原本运行正常&#xff0c;最近几天发现轮转失败&#xff0c;两个目录下的日志全部无法轮转&#xff0c;于是开始排查问题 /data01/logs/test1/*.log /data01/logs/test2/*.log {missingokrotate 1notifemptycreate 0644 www-data admsharedscrip…