当前位置:网站首页>qml 实现csdn搜索框,无规则圆角
qml 实现csdn搜索框,无规则圆角
2022-07-21 05:06:00 【ruglcc】
效果如下
代码
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.15
ApplicationWindow {
width: 640
height: 480
visible: true
title: qsTr("qml 实现csdn的搜索框,不规则圆角实现")
background: Rectangle{
anchors.fill: parent
color:"White"
}
Rectangle
{
id:searchBar
anchors.centerIn: parent
width:400
height: 35
border.color: "#fc5531"
border.width: 1
radius: searchBar.height / 2
TextInput {
anchors.leftMargin: 20
anchors.right: btn.left
anchors.left: parent.left
font.pointSize: 12
color: "Black"
y:8
maximumLength: 30
focus: true
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: {
searchBar.border.color = "#fc1944"
}
onExited: {
searchBar.border.color = "#fc5531"
}
}
}
// right button #fc1944
Rectangle {
id:btn
width: 80
height: searchBar.height
anchors.right: parent.right
anchors.top: parent.top
color: "#fc5531"
layer.enabled: true
layer.effect: OpacityMask{
maskSource: Rectangle{
width: 80
height: btn.height
radius: btn.height / 2
//左侧
Rectangle{
width: 20
height: btn.height
}
}
}
Image {
id: image_search
width: 20
height:20
x:10
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/res/img/search.png"
}
Text {
id: searchTxt
color: "White"
text: qsTr("搜索")
anchors.verticalCenter: parent.verticalCenter
anchors.left:image_search.right
anchors.leftMargin: 1
font.pointSize: 12
font.bold: true
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: {
btn.color = "#fc1944"
}
onExited: {
btn.color = "#fc5531"
}
}
}
}
}
边栏推荐
猜你喜欢
Small game items - mine sweeping
[C语言]请将细碎的能力函数与数组飞回光之国
Upload pictures and avatars
[C language] please fly the detailed ability functions and arrays back to the country of light
Dynamically listen for the height of DOM elements
[C语言] 选择 循环还可以这样玩 代码表白光之国
2020常州市程序设计小能手真题及题解
一场优雅“面试“的感悟
第五局 阿卡丽教学局 下
Solve the problem that Safari browser blocks window open
随机推荐
Moment custom time interval
第四局 匹配 上 数据分析
Output statements on the console
一场优雅“面试“的感悟
Stop pulling, stop pulling, read it in pieces
MySQL之账号管理.建库以及四大引擎
Format time
碎碎念 碎碎念 起稿
重置表单
Deep analysis of string -- StrCmp & strncmp
图片上传
第五局 阿卡丽教学局 下
The fifth Bureau, akali teaching Bureau
2020常州市程序设计小能手真题及题解
Fifth Bureau akali teaching Bureau
今天不拉扯了 不拉扯了 碎碎念 上
P1364 hospital settings
Read the manuscript in pieces
图片懒加载
第四局 借问酒家何处有?牧童遥指杏花村 匹配几把 缓解对线压力 上