锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
Rectangle {
width: 640
height: 480
color: "#0ff90f"
Flipable {
id: flip
width: 300
height: 300
anchors.centerIn: parent
property bool flipped: false
front: Image{
anchors.fill: parent
source: "file:///C:/Users/Administrator/Desktop/11111/2099720.png"
transform: Rotation{
origin.x: flip.width / 2
origin.y: flip.height / 2
axis.x: 0
axis.y: 1
axis.z: 0
angle: 180
}
}
back: Image{
anchors.fill: parent
source: "file:///C:/Users/Administrator/Desktop/11111/2099720.png"
}
transform: Rotation{
id: rotation
origin.x: flip.width / 2
origin.y: flip.height / 2
axis.x: 0
axis.y: 1
axis.z: 0
angle: 0
}
states:State{
PropertyChanges {
target: rotation
angle: 180
}
when:flip.flipped
}
transitions: Transition{
NumberAnimation{
target:rotation
properties: "angle"
duration: 240
}
}
MouseArea {
anchors.fill: parent
onClicked: flip.flipped = !flip.flipped
}
}
}
]]>
Rectangle {
width: 640
height: 480
color: "#0909ff"
Flipable {
id: flip
width: 300
height: 300
anchors.centerIn: parent
property bool flipped: false
front:Image{
anchors.fill: parent
source: "file:///C:/Users/Administrator/Desktop/11111/2099720.png"
}
back:Image{
anchors.fill: parent
source: "file:///C:/Users/Administrator/Desktop/11111/2099720-flip.png"
}
transform: Rotation{
id: rotation
origin.x: flip.width / 2
origin.y: flip.height / 2
axis.x: 0
axis.y: 1
axis.z: 0
angle: 0
}
states:State{
PropertyChanges {
target: rotation
angle: 180
}
when:flip.flipped
}
transitions: Transition{
NumberAnimation{
target:rotation
properties: "angle"
duration: 240
}
}
MouseArea {
anchors.fill: parent
onClicked: flip.flipped = !flip.flipped
}
}
}
]]>
import QtQuick.Layouts 1.3
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
Rectangle {
width: 640
height: 480
color: "#333333"
Button {
id: button
text: "Button"
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 6
onClicked: {
var count = layout.count
if(layout.currentIndex == count - 1)
layout.currentIndex = 0
else
layout.currentIndex ++
}
}
StackLayout {
id: layout
anchors.top: button.bottom
anchors.topMargin: 6
anchors.horizontalCenter: parent.horizontalCenter
width: 480
height: 320
currentIndex: 1
Rectangle {
color: 'teal'
implicitWidth: 200
implicitHeight: 200
}
Rectangle {
color: 'plum'
implicitWidth: 300
implicitHeight: 200
}
Rectangle {
color: '#c90909'
implicitWidth: 300
implicitHeight: 200
}
Rectangle {
color: 'green'
implicitWidth: 300
implicitHeight: 200
}
Rectangle {
color: 'grey'
implicitWidth: 300
implicitHeight: 200
}
}
}
]]>
import QtQuick.Layouts 1.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
Rectangle {
id: circularProgressBar
width: 60
height: 60
color: "#333333"
property real currentValue: 86
property bool textVisible: true
property bool canClick: false
Canvas {
id: canvas
anchors.fill: parent
antialiasing: true
property color primaryColor: "transparent"
property color secondaryColor: "lightblue"
property real centerWidth: width / 2
property real centerHeight: height / 2
property real radius: Math.min(canvas.width-10, canvas.height-10) / 2
property real minimumValue: 0
property real maximumValue: 100
property alias currentValue : circularProgressBar.currentValue
property string text: "0"
property real angle: (currentValue - minimumValue) / (maximumValue - minimumValue) * 2 * Math.PI
property real angleOffset: -Math.PI / 2
property real rotate: 0.0
onPrimaryColorChanged: requestPaint()
onSecondaryColorChanged: requestPaint()
onMinimumValueChanged: requestPaint()
onMaximumValueChanged: requestPaint()
onCurrentValueChanged: requestPaint()
onRotateChanged: requestPaint()
onPaint: {
var ctx = getContext("2d");
ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.translate(width/2,height/2)
ctx.rotate(rotate*Math.PI/180.0)
ctx.translate(-width/2,-height/2)
ctx.beginPath();
ctx.lineWidth = 10;
ctx.strokeStyle = primaryColor;
ctx.arc(canvas.centerWidth,
canvas.centerHeight,
canvas.radius,
angleOffset + canvas.angle,
angleOffset + 2*Math.PI);
ctx.stroke();
ctx.beginPath();
ctx.lineWidth = 3;
ctx.strokeStyle = canvas.secondaryColor;
ctx.arc(canvas.centerWidth,
canvas.centerHeight,
canvas.radius,
canvas.angleOffset,
canvas.angleOffset + canvas.angle);
ctx.stroke();
ctx.restore();
}
MouseArea {
id: mouseArea
anchors.fill: parent
visible: circularProgressBar.canClick
onClicked: canvas.clicked()
onPressedChanged: canvas.requestPaint()
}
Timer{
id: timer
interval: 150;
running: true
repeat: true;
onTriggered: {
canvas.rotate += 5
}
}
}
}
]]>
import QtQuick.Controls 2.4
Rectangle
{
width:640
height:480
color:"#cfcfc0"
anchors.margins: 6
property bool load1: true
Button
{
id:button
text: "Button"
anchors.horizontalCenter: parent.horizontalCenter
onClicked:
{
if(area.visible)
fadeOut.start()
else
fadeIn.start()
}
}
PropertyAnimation
{
id: fadeOut
target: area
duration: 300
property: "opacity"
from: 1.0
to: 0.0
onStopped: area.visible = false
}
PropertyAnimation
{
id: fadeIn
target: area
duration: 300
property: "opacity"
from: 0.0
to: 1.0
onStarted: area.visible = true
}
Rectangle
{
id: area
width: parent.width - 12
height: parent.height - button.height - 12
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 6
anchors.top: button.bottom
visible: false
color: "#9900ff00"
}
}
]]>
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
}
]]>
import QtQuick.Controls 2.4
Rectangle
{
width:640
height:480
color:"#cfcfc0"
anchors.margins: 6
MouseArea {
id: mouseRegion
anchors.fill: parent;
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if(mouse.button == Qt.RightButton)
contentMenu.popup()
}
Menu {
id: contentMenu
MenuItem {
text: "Cut"
onTriggered: {}
}
MenuItem {
text: "Copy"
onTriggered: {}
}
MenuItem {
text: "Paste"
onTriggered: {}
}
MenuSeparator { }
Menu {
title: "More"
MenuItem {
text: "Edit"
}
MenuItem {
text: "Select All"
}
}
}
}
}
]]>
2 anchors.left: button
3 text: "鑿滃崟"
4 anchors.leftMargin: 12
5 onClicked: popupMenu.popup()
6 }
7
8 Menu {
9 id : popupMenu
10 title: "&File"
11
12 MenuItem {
13 text: "&Open"
14 onTriggered:{}
15 }
16
17 MenuItem {
18 text: "&Save"
19 onTriggered: {}
20 }
21
22 MenuItem {
23 text: "&Close"
24 onTriggered: Qt.quit()
25 }
26 }
]]>
import QtQuick.Layouts 1.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
Rectangle {
id: circularProgressBar
width: 60
height: 60
color: "#333333"
property real currentValue: 0
property bool textVisible: true
property bool canClick: false
Canvas {
id: canvas
anchors.fill: parent
antialiasing: true
property color primaryColor: "transparent"
property color secondaryColor: "lightblue"
property real centerWidth: width / 2
property real centerHeight: height / 2
property real radius: Math.min(canvas.width-10, canvas.height-10) / 2
property real minimumValue: 0
property real maximumValue: 100
property alias currentValue : circularProgressBar.currentValue
property string text: "0"
property real angle: (currentValue - minimumValue) / (maximumValue - minimumValue) * 2 * Math.PI
property real angleOffset: -Math.PI / 2
onPrimaryColorChanged: requestPaint()
onSecondaryColorChanged: requestPaint()
onMinimumValueChanged: requestPaint()
onMaximumValueChanged: requestPaint()
onCurrentValueChanged: requestPaint()
onPaint: {
var ctx = getContext("2d");
ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
if(mouseArea.pressed) {
ctx.beginPath();
ctx.lineWidth = 10;
ctx.fillStyle = Qt.lighter(canvas.secondaryColor,1.25);
ctx.arc(canvas.centerWidth,
canvas.centerHeight,
canvas.radius,
0,
2*Math.PI);
ctx.fill();
timer.running = true;
}
ctx.beginPath();
ctx.lineWidth = 10;
ctx.strokeStyle = primaryColor;
ctx.arc(canvas.centerWidth,
canvas.centerHeight,
canvas.radius,
angleOffset + canvas.angle,
angleOffset + 2*Math.PI);
ctx.stroke();
ctx.beginPath();
ctx.lineWidth = 3;
ctx.strokeStyle = canvas.secondaryColor;
ctx.arc(canvas.centerWidth,
canvas.centerHeight,
canvas.radius,
canvas.angleOffset,
canvas.angleOffset + canvas.angle);
ctx.stroke();
ctx.restore();
}
Text {
id: progressText
anchors.centerIn: parent
font.pixelSize: 16
text: canvas.text
visible: circularProgressBar.textVisible
color: canvas.secondaryColor
}
MouseArea {
id: mouseArea
anchors.fill: parent
visible: circularProgressBar.canClick
onClicked: canvas.clicked()
onPressedChanged: canvas.requestPaint()
}
Timer{
id: timer
interval: 100;
running: true
repeat: true;
onTriggered: {
if(circularProgressBar.currentValue === 100) {
circularProgressBar.currentValue = 0;
progressText.text = "0"
}
circularProgressBar.currentValue += 1;
progressText.text = circularProgressBar.currentValue.toString()+"%";
}
}
}
}
]]>
import QtQuick.Controls 2.4
Rectangle
{
id: base
width:640
height:480
color: backgroundColor
property string backgroundColor: "#191919"
anchors.margins: 6
Rectangle {
id: seekTimeBubble
width: currentSeekTime.width + 14
height: currentSeekTime.height + 21
anchors.centerIn: parent
color: parent.color
Canvas {
id: canvasSeekTime
anchors.fill: parent
property real radius: 9
onPaint: {
var ctx = getContext('2d')
ctx.reset()
ctx.strokeStyle = base.color
ctx.lineWidth = 1
ctx.clearRect(0, 0, width, height)
ctx.beginPath()
ctx.moveTo(0, radius)
ctx.arcTo(0, 0, radius, 0,radius)
ctx.lineTo(parent.width - radius, 0)
ctx.arcTo(parent.width, 0, parent.width, radius, radius)
ctx.lineTo(parent.width, parent.height - radius * 2)
ctx.arcTo(parent.width, parent.height - radius,parent.width - radius,parent.height - radius, radius)
ctx.lineTo(parent.width / 2 + 1.5*radius,parent.height - radius)
ctx.lineTo(parent.width / 2, parent.height)
ctx.lineTo(parent.width / 2 - 1.5*radius,parent.height - radius)
ctx.lineTo(radius, parent.height - radius)
ctx.arcTo(0, parent.height - radius, 0, parent.height - radius * 2, radius)
ctx.closePath()
ctx.clip()
ctx.stroke()
ctx.fillStyle = "#333333"
ctx.fillRect(0, 0, width, height)
}
Text {
id: currentSeekTime
anchors {
top: parent.top
topMargin: 3
horizontalCenter: parent.horizontalCenter
}
color: "#ffffff"
font.pointSize: 12
text: "03:21"
onWidthChanged: {
canvasSeekTime.requestPaint()
}
}
}
Glow {
anchors.fill: canvasSeekTime
samples: 17
color: "transparent"
source: canvasSeekTime
}
}
}
]]>
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
Rectangle {
id: container
width: 640
height: 360
StackLayout {
id: layout
width: parent.width - 120
height: 300
anchors.top: parent.top
anchors.topMargin: 6
anchors.horizontalCenter: parent.horizontalCenter
currentIndex: count - 1
Rectangle {
color: 'teal'
implicitWidth: 200
implicitHeight: 200
}
Rectangle {
color: 'plum'
implicitWidth: 300
implicitHeight: 200
}
Rectangle {
color: 'red'
implicitWidth: 300
implicitHeight: 200
}
Rectangle {
color: 'blue'
implicitWidth: 300
implicitHeight: 200
}
Rectangle {
color: 'green'
implicitWidth: 300
implicitHeight: 200
}
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: layout.bottom
anchors.topMargin: 6
text: "Prev"
onClicked:{
if(layout.currentIndex == 0)
layout.currentIndex = layout.count-1
else {
layout.currentIndex --
}
}
}
}
]]>
import QtQuick.Controls 1.2
Rectangle {
id: doubleSlider
width: 360
height: 72
color: "#c3c3c3"
property int minValue: 0
property int maxValue: 100
property int lowValue: 0
property int highValue: 100
property int thumbWidth: 12
readonly property int range: width - thumbWidth
property var thumbColor: "#c030bb"
property int lastX: 0
signal value(int low,int high)
Rectangle {
id: startSlider
width: doubleSlider.thumbWidth
height: parent.height
x: 0
anchors.verticalCenter: parent.verticalCenter
color: doubleSlider.thumbColor
}
Rectangle {
id: endSlider
width: doubleSlider.thumbWidth
height: parent.height
x: parent.width - endSlider.width
anchors.verticalCenter: parent.verticalCenter
color: doubleSlider.thumbColor
}
MouseArea {
id: sliderMouseArea
anchors.fill: parent
hoverEnabled: true
property point clickPos
property var currentSlider: undefined
onPressed: {
updateCurrentSlider(mouse)
clickPos = Qt.point(mouse.x,mouse.y)
}
onPositionChanged:{
if(pressed && currentSlider != undefined){
var delta = Qt.point(mouse.x-clickPos.x,mouse.y-clickPos.y)
doubleSlider.lastX = currentSlider.x
currentSlider.x = mouse.x
fixSliderPosition()
}
}
onWheel: {
if(currentSlider === undefined)
return
var delta = wheel.angleDelta.y/120
currentSlider.x += delta
fixSliderPosition()
}
function fixSliderPosition(){
if(currentSlider === undefined)
return
if(currentSlider === startSlider &&
startSlider.x+startSlider.width > endSlider.x)
currentSlider.x = endSlider.x-startSlider.width
if(currentSlider === endSlider &&
endSlider.x < startSlider.x + startSlider.width)
currentSlider.x = startSlider.x + startSlider.width
if(currentSlider.x < 0)
currentSlider.x = 0
if(currentSlider.x > doubleSlider.width - currentSlider.width)
currentSlider.x = doubleSlider.width - currentSlider.width
if(currentSlider === startSlider){
var v0 = 100*startSlider.x/doubleSlider.range
if(v0 != lowValue){
lowValue = v0
doubleSlider.value(lowValue,highValue)
}
}
else if(currentSlider === endSlider){
var v1 = 100*endSlider.x/doubleSlider.range
if(v1 != highValue){
highValue = v1
doubleSlider.value(lowValue,highValue)
}
}
}
function containPoint(input,minValue,maxValue){
if(input < minValue || input > maxValue)
return false
return true
}
function updateCurrentSlider(mouse){
if(containPoint(mouse.x,startSlider.x,startSlider.x+startSlider.width)){
currentSlider = startSlider
doubleSlider.lastX = startSlider.x
}
else if(containPoint(mouse.x,endSlider.x,endSlider.x+endSlider.width)){
currentSlider = endSlider
doubleSlider.lastX = endSlider.x
}
}
}
}
]]>
import QtQuick.Controls 2.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Window 2.11
import QtQuick.Layouts 1.1
Rectangle
{
anchors.rightMargin: 4
anchors.bottomMargin: 4
anchors.leftMargin: 4
anchors.topMargin: 4
anchors.fill: parent
ColumnLayout
{
spacing: 2
anchors.fill: parent
Rectangle
{
Layout.fillWidth: true
Layout.fillHeight: true
RowLayout {
anchors.fill: parent
Rectangle
{
Layout.fillWidth: true
Layout.fillHeight: true
ListView {
id:idLogListView
focus:true
anchors.fill: parent
highlight: Rectangle { color: "#A0CED1" }
model: idListModle
delegate: Component
{
RowLayout {
id:idlistElemnet
height: 20
width: parent.width
spacing: 20
Layout.fillWidth: true
Rectangle {height: 16
width: 16
radius: 5
color:getListEleHeadColor(type)
Text{ anchors.centerIn: parent}
}
Text { text: time; font.bold: true}
Text { text:type }
Text { text:descripe; color:"blue" ; Layout.fillWidth: true}
states: State {
name: "Current"
when: idlistElemnet.ListView.isCurrentItem
PropertyChanges { target: idlistElemnet; x: 20 }
}
transitions: Transition {
NumberAnimation { properties: "x"; duration: 200 }
}
MouseArea {
anchors.fill: parent
onClicked: idlistElemnet.ListView.view.currentIndex = index
}
}
}
Component.onCompleted:
{
for(var idx=0;idx<100;idx++)
{
var newType=parseInt((Math.random(Math.random())*100+1)%3);
idListModle.append( { "descripe": "緋葷粺鏃ュ織




..","time": "2016-10-2","type":newType});
}
}
}
ListModel {
id:idListModle
ListElement {
descripe: "緋葷粺鏃ュ織





"
time: "2016-11-2"
type:1
}
}
}
Rectangle
{
Layout.fillHeight: true
id: scrollbar
width: 10;
height: 380
color: "#D9D9D9"
radius: 10
Rectangle {
id: button
x: 0
y: idLogListView.visibleArea.yPosition * scrollbar.height
width: 10
height: idLogListView.visibleArea.heightRatio * scrollbar.height;
color: "#979797"
radius: 10
MouseArea {
id: mouseArea
anchors.fill: button
drag.target: button
drag.axis: Drag.YAxis
drag.minimumY: 0
drag.maximumY: scrollbar.height - button.height
onMouseYChanged: {
idLogListView.contentY = button.y / scrollbar.height * idLogListView.contentHeight
}
}
}
}
}
}
Rectangle
{
Layout.preferredHeight: 40
Layout.fillWidth: true
Layout.minimumHeight:40
}
}
function getListEleHeadColor(ntype)
{
switch(ntype)
{
case 0:
return "lightblue"
case 1:
return "red";
case 2:
return "yellow";
case 3:
return "green";
default:
return "black";
}
}
}
]]>
Rectangle{
id: rootItem
width: 360
height: 360
color: "#cfcfcf"
property int targetWidth: 0
Rectangle{
id: rect1
width:360
height:rootItem.height
color:"#808080"
}
Rectangle{
id: rect2
width:rootItem.width-rect1.width
height:parent.height
x:rootItem.width
color:"#c0c0c0"
}
Button{
text: "Button"
anchors.centerIn: parent
onClicked: {
animation.start()
}
}
NumberAnimation{
id: animation
target: rect1
properties: "width"
to: rootItem.targetWidth
duration: 720
onStopped: rootItem.targetWidth = rootItem.width - to
}
}
]]>
import QtQuick.Controls 1.4
Rectangle{
id: rect1
width: 640
height: 480
ListModel{
id:libraryModel
ListElement{title: "aaa"; author: "AAA"}
ListElement{title: "bbb"; author: "BBB"}
ListElement{title: "ccc"; author: "ccc"}
}
TableView{
anchors.fill: parent
model:libraryModel
TableViewColumn{role:"title"; title: "Title"; width: 100}
TableViewColumn{role:"author"; title: "Author"; width: 200}
rowDelegate: Rectangle{
height: 50
color: styleData.selected?"#f0b0b0af":(styleData.alternate?"#c3c3c0":"#c0c0c3")
}
itemDelegate: Rectangle {
height: 50
color: "transparent"
Text {
//anchors.centerIn: parent
anchors.left: parent.left
anchors.leftMargin: 6
anchors.verticalCenter: parent.verticalCenter
color: styleData.textColor
text: styleData.value
verticalAlignment: Text.AlignVCenter
font.pointSize: 13
}
}
}
}
]]>
Rectangle{
id: rootItem
width: 360
height: 360
color: "#cfcfcf"
Rectangle{
id: rect
width: 50
height: 50
x: 0
y: 5
color: "#c0c0ff"
MouseArea{
id: mouseArea
anchors.fill: parent
onClicked: {
animation.newHeight = 60
animation.start()
}
}
ParallelAnimation{
id: animation
property int newHeight: 240
NumberAnimation{
target: rootItem
properties: "height"
to: animation.newHeight
duration: 300
}
NumberAnimation{
target: rootItem
properties: "y"
to: y + (height-animation.newHeight)*0.5
duration: 300
}
}
}
}
]]>
Rectangle{
id: rootItem
width: 360
height: 240
color: "#cfcfcf"
Rectangle{
id: rect
width: 50
height: 50
x: 0
y: 5
color: "#c0c0ff"
MouseArea{
id: mouseArea
anchors.fill: parent
onClicked: {
animation.start()
}
}
ParallelAnimation{
id: animation
NumberAnimation{
target: rect
properties: "x"
to: 100
duration: 300
}
NumberAnimation{
target: rect
properties: "y"
to: 100
duration: 300
}
}
}
}
]]>
]]>
Rectangle {
id: item1
x: 0; width: 80; height: 80
color: "#0000FF"
}
Rectangle {
id:item2
x: 100; width: 80; height: 80
color: Qt.tint(item1.color, "#80FF0000")
}
}
]]>
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
Rectangle
{
width: 640
height: 450
ListModel
{
id: objmodel
ListElement
{
name: "寮犻"
}
ListElement
{
name: "鍗庝綏"
}
ListElement
{
name: "鏈辨不"
}
ListElement
{
name: "鍏瓩搴?
}
ListElement
{
name: "琚佹湰鍒?
}
ListElement
{
name: "鏉ㄦ澗"
}
}
Component
{
id: delegateItem
Item
{
id: wrapper
width: parent.width
height: 30
Text
{
id: coll
text: name
font.pointSize: 13
color: wrapper.ListView.isCurrentItem? "red":"black"
}
MouseArea
{
id: mousearea
anchors.fill: parent
onClicked:listview.currentIndex = index;
onMouseXChanged:
{
var pore = listview.indexAt(mousearea.mouseX + wrapper.x, mousearea.mouseY + wrapper.y);
if(index !== pore )
{
objmodel.move(index,pore,1)
}
}
onMouseYChanged:
{
var pore = listview.indexAt(mousearea.mouseX + wrapper.x, mousearea.mouseY + wrapper.y);
if(index !== pore)
{
objmodel.move(index,pore,1)
}
}
}
}
}
ListView
{
id: listview
width:240
height:180
anchors.centerIn: parent
delegate: delegateItem
model:objmodel
interactive: false
focus: true
move: Transition
{
NumberAnimation { properties: "x,y"; duration: 2100 }
}
}
}
]]>
import QtQuick.Controls 2.4
Rectangle
{
width:640
height:480
color:"#cfcfc0"
anchors.margins: 6
property bool load1: true
Button
{
id:button
text:"鐐瑰嚮鍔犺澆Loader"
anchors.horizontalCenter: parent.horizontalCenter
onClicked:
{
if(parent.load1)
{
loader.source = "SubRect1.qml"
parent.load1 = false
}
else
{
loader.source = "SubRect2.qml"
parent.load1 = true
}
}
}
Loader
{
id:loader
width: parent.width - 12
height: parent.height - button.height - 12
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 6
anchors.top: button.bottom
}
}
import QtQuick.Controls 2.4
Rectangle
{
width:480
height:320
color:"#0fefc0"
Component.onCompleted:
{
console.log("SubRect1.qml loaded")
}
/*Component.onDestroyed:
{
console.log("SubRect1.qml onDestroyed")
}*/
Component.onDestruction:
{
console.log("SubRect1.qml onDestructed")
}
}
]]>
import QtQuick.Controls 2.4
Rectangle
{
width:640
height:480
color:"#cfcfc0"
DropArea
{
id: droparea
anchors.fill: parent
property bool hasUrls: false
enabled: true
onDropped:
{
if(drop.hasUrls)
{
var files = drop.urls
console.log("drop files:",files)
}
}
onEntered:
{
console.log("extered.")
}
}
}
]]>
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0
Rectangle
{
visible: true
width: 400
height: 300
Text
{
id: textID
height: 240
width: 240
anchors.centerIn: parent
text:"鐐瑰嚮榧犳爣鍙棆杞枃瀛?
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: 13
MouseArea
{
anchors.fill: parent
onClicked:
{
if(rotationAnimation.running === true)
return;
rotationAnimation.start();
}
}
LinearGradient
{
source: textID
width: 240
height: 240
gradient: Gradient
{
GradientStop
{
position: 0.0
color: "#22F222"
}
GradientStop
{
position: 0.9
color: "#F0280F"
}
}
start: Qt.point(0,0)
end: Qt.point(240,240)
}
}
RotationAnimation
{
id: rotationAnimation
target: textID
from: currentAngle
to: currentAngle+diff
duration: 100
readonly property int diff: 5
property int currentAngle: 0
property bool isDown: true
onStopped:
{
rotationAnimation.from = rotationAnimation.to
rotationAnimation.to = rotationAnimation.to+diff;
}
}
}
]]>
#include <QtPlugin>
#include <QObject>
struct AddonInfo
{
QString name;
QString description;
QString version;
QString author;
};
class AddonInterface : public QObject
{
Q_OBJECT
public:
virtual ~AddonInterface() {}
virtual AddonInfo addonInfo()const { return AddonInfo(); }
};
Q_DECLARE_INTERFACE(AddonInterface,"com.ppx.addon.interface/1.0")
class AddonInterfaceIMPL : public AddonInterface
{
Q_OBJECT
public:
AddonInfo addonInfo()const;
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "com.ppx.addon.interface")
Q_INTERFACES(AddonInterface);
#endif
};
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2(FilterInterface,plugin)
#endif // QT_VERSION < 0x050000
AddonInfo AddonInterfaceIMPL::addonInfo()const
{
AddonInfo addon;
addon.name = "MyAddOn";
addon.author = "Coder";
addon.description = "Description";
addon.version = "1.0";
return addon;
}
#include <qpluginloader.h>
#include <qdebug>
#include "addon.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QPluginLoader loader("addon.dll");
qDebug()<<"load plugin :"<<loader.load();
auto object = loader.instance();
qDebug() << "object:" << object;
if (object)
{
AddonInterface* face = qobject_cast<AddonInterface*>(object);
qDebug() << "face ptr:"<<face;
auto info = face->addonInfo();
qDebug() << info.author << " " << info.description << " " << info.name << " " << info.version;
}
return a.exec();
}
]]>
Rectangle
{
id: dragBackground
visible: true
color: "#dad1db"
width:720
height:480
DragRectangle
{
z: 10
id:dragRectangle
width: 480
height:240
Component.onCompleted:
{
dragBackground.makeViewCenter(dragRectangle)
}
}
function makeViewCenter(view)
{
var cx = (width-view.width)*0.5
var cy = (height-view.height)*0.5
view.x = cx
view.y = cy
}
}
Rectangle
{
id:resizeRectangle
property int enableSize: 12
property bool isPressed: false
property point customPoint
color: "#00debff3"
border.color: "#d37e49"
readonly property int minWidth: 64
readonly property int minHeight: 64
MouseArea
{
id: mouseArea
anchors.fill: resizeRectangle
drag.target: parent
onWheel:
{
var diff_w = 0.0
var diff_h = 0.0
if(wheel.angleDelta.y > 0)
{
diff_w = resizeRectangle.width * 0.02
diff_h = resizeRectangle.height * 0.02
}
else if(wheel.angleDelta.y < 0)
{
diff_w = -resizeRectangle.width * 0.02
diff_h = -resizeRectangle.height * 0.02
}
else
{
resizeRectangle.width = width
resizeRectangle.height = height
}
fixedRetangle(diff_w,diff_h)
drag.minimumX = 0
drag.maximumX = dragBackground.width - resizeRectangle.width
drag.minimumY = 0
drag.maximumY = dragBackground.height - resizeRectangle.height
}
}
Item
{
id: leftTop
width: enableSize
height: enableSize
anchors.left: parent.left
anchors.top: parent.top
MouseArea
{
anchors.fill: parent
hoverEnabled: true
onPressed: press(mouse)
onEntered: enter(1)
onReleased: release()
onPositionChanged: positionChange(mouse, -1, -1)
}
}
Item
{
id: top
height: enableSize
anchors.left: leftTop.right
anchors.right: rightTop.left
anchors.top: parent.top
MouseArea
{
anchors.fill: parent
hoverEnabled: true
onPressed: press(mouse)
onEntered: enter(2)
onReleased: release()
onMouseYChanged: positionChange(Qt.point(customPoint.x, mouseY), 1, -1)
}
}
Item
{
id: rightTop
width: enableSize
height: enableSize
anchors.right: parent.right
anchors.top: parent.top
MouseArea
{
anchors.fill: parent
hoverEnabled: true
onPressed: press(mouse)
onEntered: enter(3)
onReleased: release()
onPositionChanged: positionChange(mouse, 1, -1)
}
}
Item
{
id: left
width: enableSize
anchors.left: parent.left
anchors.top: leftTop.bottom
anchors.bottom: leftBottom.top
MouseArea
{
anchors.fill: parent
hoverEnabled: true
onPressed: press(mouse)
onEntered: enter(4)
onReleased: release()
onMouseXChanged: positionChange(Qt.point(mouseX, customPoint.y), -1, 1)
}
}
Item
{
id: center
anchors.left: left.right
anchors.right: right.left
anchors.top: top.bottom
anchors.bottom: bottom.top
MouseArea
{
anchors.fill: parent
property point clickPos
onPressed: clickPos = Qt.point(mouse.x,mouse.y)
onPositionChanged:
{
if(pressed)
{
var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
resizeRectangle.x += delta.x
resizeRectangle.y += delta.y
fixedRetangle(0,0)
}
}
}
}
Item
{
id: right
width: enableSize
anchors.right: parent.right
anchors.top: rightTop.bottom
anchors.bottom: rightBottom.top
MouseArea
{
anchors.fill: parent
hoverEnabled: true
onPressed: press(mouse)
onEntered: enter(6)
onReleased: release()
onMouseXChanged: positionChange(Qt.point(mouseX, customPoint.y), 1, 1)
}
}
Item
{
id: leftBottom
width: enableSize
height: enableSize
anchors.left: parent.left
anchors.bottom: parent.bottom
MouseArea
{
anchors.fill: parent
hoverEnabled: true
onPressed: press(mouse)
onEntered: enter(7)
onReleased: release()
onPositionChanged: positionChange(mouse, -1, 1)
}
}
Item
{
id: bottom
height: enableSize
anchors.left: leftBottom.right
anchors.right: rightBottom.left
anchors.bottom: parent.bottom
MouseArea
{
anchors.fill: parent
hoverEnabled: true
onPressed: press(mouse)
onEntered: enter(8)
onReleased: release()
onMouseYChanged: positionChange(Qt.point(customPoint.x, mouseY), 1, 1)
}
}
Item
{
id:rightBottom
width: enableSize
height: enableSize
anchors.right: parent.right
anchors.bottom: parent.bottom
MouseArea
{
anchors.fill: parent
hoverEnabled: true
onPressed: press(mouse)
onEntered: enter(9)
onReleased: release()
onPositionChanged: positionChange(mouse,1,1)
}
}
function fixedRetangle(dx,dy)
{
if(resizeRectangle.width <= minWidth && resizeRectangle.height <= minHeight && dx <=0 && dy <= 0)
return
resizeRectangle.x -= dx*0.5
resizeRectangle.y -= dy*0.5
resizeRectangle.width += dx
resizeRectangle.height += dy
if(resizeRectangle.width < minWidth)
resizeRectangle.width = minWidth
if(resizeRectangle.height < minHeight)
resizeRectangle.height = minHeight
if(resizeRectangle.width > dragBackground.width)
resizeRectangle.width = dragBackground.width
if(resizeRectangle.height > dragBackground.height)
resizeRectangle.height = dragBackground.height
if(resizeRectangle.width + resizeRectangle.x > dragBackground.width)
resizeRectangle.x = dragBackground.width - resizeRectangle.width
if(resizeRectangle.height + resizeRectangle.y > dragBackground.height)
resizeRectangle.y = dragBackground.height - resizeRectangle.height
if(resizeRectangle.y < 0)
resizeRectangle.y = 0
if(resizeRectangle.x < 0)
resizeRectangle.x = 0
}
function enter(direct)
{
}
function press(mouse)
{
isPressed = true
customPoint = Qt.point(mouse.x, mouse.y)
}
function release()
{
isPressed = false
}
function positionChange(newPosition,directX, directY)
{
if(!isPressed)
return
var delta = Qt.point(newPosition.x-customPoint.x, newPosition.y-customPoint.y)
var tmpW,tmpH
if(directX >= 0)
tmpW = resizeRectangle.width + delta.x
else
tmpW = resizeRectangle.width - delta.x
if(directY >= 0)
tmpH = resizeRectangle.height + delta.y
else
tmpH = resizeRectangle.height - delta.y
if(tmpW < resizeRectangle.minimumWidth)
{
if(directX < 0)
resizeRectangle.x += (resizeRectangle.width - resizeRectangle.minimumWidth)
resizeRectangle.width = resizeRectangle.minimumWidth
}
else
{
resizeRectangle.width = tmpW
if(directX < 0)
resizeRectangle.x += delta.x
}
if(tmpH < resizeRectangle.minimumHeight)
{
if(directY < 0)
resizeRectangle.y += (resizeRectangle.height - resizeRectangle.minimumHeight)
resizeRectangle.height = resizeRectangle.minimumHeight
}
else
{
resizeRectangle.height = tmpH
if(directY < 0)
resizeRectangle.y += delta.y
}
fixedRetangle(0,0)
}
}
]]>
{
unsigned int* data = (unsigned int*)image.bits();
int size = image.width()*image.height();
QColor color;
for(int i = 0; i < size; i++)
{
int red = qRed(data[i]);
int green = qGreen(data[i]);
int blue = qBlue(data[i]);
color.setRed(red);
color.setGreen(green);
color.setBlue(blue);
qreal h = color.hueF() + hue;
qreal s = color.saturationF() + saturation;
qreal l = color.lightnessF() + lightness;
h = qBound<qreal>(0,h,1);
s = qBound<qreal>(0,s,1);
l = qBound<qreal>(0,l,1);
color.setHslF(h,s,l);
color.setAlpha(qAlpha(data[i]));
data[i] = qRgba(color.red(),color.green(),color.blue(),color.alpha());
}
return;
}
]]>
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
Popup
{
width: 360
height: 90
modal: true
focus: true
opacity: 0.96
function setWarningText(input)
{
warningText.text = input
}
Text
{
id:warningText
anchors.centerIn: parent
text: "WarningText"
}
}
]]>
Item
{
visible: true
width: 1620
height: 720
id:background
Image
{
source: "images/2560.png"
anchors.fill: parent
}
Flickable
{
id: flick
anchors.top: parent.top;
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 3
contentWidth: 0
contentHeight: 0
clip: true
Image
{
id: image
smooth: true
transformOrigin: Item.Center
source:"mark.png"
onStatusChanged:
{
if(status === Image.Ready)
{
image.width *= 0.5
image.height *= 0.5
image.x = background.width*0.5-0.5*image.width
image.y = background.height*0.5-0.5*image.height
/*mouseArea.drag.minimumX = 0
mouseArea.drag.maximumX = flick.width - image.width
mouseArea.drag.minimumY = 0
mouseArea.drag.maximumY = flick.height - image.height*/
}
}
}
}
function makeImageCenter(imageWidth,imageHeight)
{
var cx = image.x + 0.5*image.width
var cy = image.y + 0.5*image.height
image.width = imageWidth
image.height = imageHeight
image.x = cx - image.width*0.5
image.y = cy - image.height*0.5
}
MouseArea
{
id: mouseArea
anchors.fill: flick
drag.target: image
onWheel:
{
var diff_w = 0.0
var diff_h = 0.0
if(wheel.angleDelta.y > 0)
{
diff_w = image.width * 0.02
diff_h = image.height * 0.02
}
else if(wheel.angleDelta.y < 0)
{
diff_w = -image.width * 0.02
diff_h = -image.height * 0.02
}
else
{
image.width = width
image.height = height
}
if(wheel.angleDelta.y != 0)
background.makeImageCenter(image.width+diff_w,image.height+diff_h)
drag.minimumX = 0
drag.maximumX = flick.width - image.width
drag.minimumY = 0
drag.maximumY = flick.height - image.height
}
}
}
]]>
{
foreach(auto object,*list)
{
auto current = new QStandardItem();
current->setText(object->objectName());
item->appendRow(current);
auto chidren = object->children();
if(!chidren.isEmpty())
buildTreeItem(&chidren,current);
}
}
void buildTree(QTreeView* view,const QList<QObject*>& list)
{
view->header()->hide();
view->setColumnHidden(0,true);
QStandardItemModel* model = new QStandardItemModel(view);
foreach(auto object,list)
{
auto item = new QStandardItem(object->objectName());
auto list = object->children();
buildTreeItem(&list,item);
model->appendRow(item);
}
view->setModel(model);
}
QObject* buildObjectTree(QObject* parent,const QString& text)
{
auto object = new QObject(parent);
object->setObjectName(text);
return object;
}
QWidget widget;
auto box = new QVBoxLayout();
widget.setLayout(box);
QTreeView* tree = new QTreeView(&widget);
box->addWidget(tree);
QList<QObject*> list;
auto object = buildObjectTree(nullptr,"1");
list.append(object);
buildObjectTree(object, "2");
buildObjectTree(object, "3");
object = buildObjectTree(object, "4");
buildObjectTree(object, "5");
buildObjectTree(object, "6");
object = buildObjectTree(object, "7");
buildObjectTree(object, "8");
buildObjectTree(object, "9");
buildObjectTree(object, "10");
buildObjectTree(object, "11");
buildTree(tree,list);
widget.show();
]]>
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return cppobject;
}
]]>