qml 图片浏览器旋转、按鼠标缩放
看看这些90后都开始付费了,我也来赶个时髦,要的自取:
代码很简单的,2个文件:
import QtQuick 2.11
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2Item {id:buttonproperty string text: "button"signal myClickedimplicitWidth: 70;implicitHeight: parent.height; // 35anchors.leftMargin: 8anchors.bottom: parent.bottom//anchors.bottomMargin: 8Button {id: myBtnwidth: parent.widthheight: parent.heighttext: button.textstyle: ButtonStyle {background: Rectangle {implicitWidth: parent.width; // 70implicitHeight: parent.height;// 40border.width: control.pressed ? 2 : 1;//border.color: (control.hovered || control.pressed)// ? "green" : "#888888";border.color: "transparent"radius: 5;color: (control.hovered || control.pressed)? "#0078D7" : "transparent";}label:Text{text:myBtn.text;clip:true;anchors.fill: parentcolor:"white"verticalAlignment: Text.AlignVCenterhorizontalAlignment: Text.AlignHCenterfont.pointSize: 12}}onClicked: {myClicked()}}
}
再来:
import QtQuick 2.11
import QtQuick.Window 2.11
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2Window {id: windowvisible: truewidth: 800height: 600minimumWidth: 480minimumHeight: 380title: qsTr("图片浏览器")// 定义缩放比例系数变量,范围在(-10,10)之间property double scaleValue: 1.1property int scaleLevel: 0property int imgWi