1、路径
folder: shortcuts.desktop // 桌面
folder: shortcuts.home
folder: "file:///firmware"//exe所在路径
2、文件对话框
fileDialog.open();//调用
//使用
FileDialog {
id: fileDialog;
title: qsTr("Open File");
folder: shortcuts..desktop // 桌面
nameFilters: [
"Files(*.txt)"
];
onAccepted:
{
console.log("You chose: " + fileUrl)
}
onRejected:
{
console.log("You chose: " + "")
}
}
3、控件阴影
import QtGraphicalEffects 1.0
DropShadow {
id : shadow2
anchors.fill: progressBarBg//为需要增加阴影的控件,阴影大小是按照控件来的
horizontalOffset: 1//水平偏移量
verticalOffset: 3//垂直偏移量
radius: 8.0//指定如何强化阴影接近源 Item 边缘的部分,取值范围为 0.0 -- 1.0 ,默认为 0.5
samples: 17//指定生成阴影时阴影的每个像素由多少个采样点产生,采样点越多阴影效果越好,不过也越慢。一般可以把这个值设置为 radius的2倍。
color: "#FFFFFF"
source: progressBarBg//指向源item,为需要增加阴影的控件
}
PS:按钮用这个有问题,因为按钮在设置了多种状态后,操作状态会被阴影覆盖掉
进度条例子:
ProgressBar {
anchors.top: titleText2.Bottom;//进度条顶部在这个控件下面
id: progressBar
width: 330
height: 20
from: 0
to: 100
value: 0
anchors.horizontalCenter: parent.horizontalCenter
background: Rectangle {
id: progressBarBg
implicitWidth: parent.width
implicitHeight: parent.height
border.width: 2
border.color: "#FFFFFF"
color: "transparent"//透明
radius:10
}
contentItem: Item {
implicitWidth: parent.width
implicitHeight: parent.height
Rectangle {
radius:10
x: progressBarBg.border.width + 1
y: progressBarBg.border.width + 1
width: progressBar.visualPosition * (parent.width - (progressBarBg.border.width + 1) * 2)
height: progressBarBg.implicitHeight - (progressBarBg.border.width + 1) * 2
color: "#8183F7"
}
}
DropShadow {
id : shadow2
anchors.fill: progressBarBg
horizontalOffset: 1//右
verticalOffset: 3//下
radius: 8.0
samples: 16
color: "#8183F7"
source: progressBarBg
}
}