//main.qml
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.1
Window {
visible: true
width: 600
height: 480
minimumWidth: 480
minimumHeight: 380
BusyIndicator{
id:busy
running:false
anchors.centerIn: parent
z:2
}
Text{
id:stateLable
visible:false
anchors.centerIn: parent
z:3
}
Image {
id: imageViewer
asynchronous: true
cache:false
anchors.fill: parent
fillMode: Image.PreserveAspectFit
onStatusChanged: {
if(imageViewer.status===Image.Loading){
busy.running=true;
stateLable.visible=false;
}
else if(imageViewer.status===Image.Ready){
busy.running=false;
}
else if(imageViewer.status===Image.Error){
busy.running=false;
stateLable.visible=true;
stateLable.text="ERROR";
}
}
}
Button{
id:openFile
text:"Open"
anchors.left: parent.left
anchors.leftMargin: 8
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
style: ButtonStyle{
background: Rectangle{
implicitWidth: 70
implicitHeight: 25
color:control.hovered?"#c0c0c0":"#a0a0a0"
border.width: control.passed?2:1
border.color: (control.hovered||control.passed)
?"green":"#888888"
}
}
onClicked: fileDialog.open();
z:4
}
Text{
id:imagePath
anchors.left: openFile.right
anchors.leftMargin: 8
anchors.verticalCenter: openFile.verticalCenter
font.pixelSize: 18
}
FileDialog{
id:fileDialog
title:"please choose"
nameFilters: ["Image Files(*.jpg *.png *.gif)"]
onAccepted:{
imageViewer.source=fileDialog.fileUrl
var imageFile=String(fileDialog.fileUrl)
imagePath.text=String(imageFile.substring(8,imageFile.length))
}
}
}
Qt quick 图片查看器
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 1.使用win+R快捷键快速打开运行,输入regedit打开注册表 2.在注册表中找到HKEY_LOCAL_MAC...
- Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\...
- 1.使用win+R快捷键快速打开运行,输入regedit打开注册表 2.在注册表中找到 3.在右侧新建字符串项 需...