Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
BalaSwecha
Density
Commits
1cb54afb
Commit
1cb54afb
authored
Sep 14, 2014
by
Ganesh Katrapati
Browse files
Sinking
parent
96b5c37c
Changes
3
Hide whitespace changes
Inline
Side-by-side
qml/Example1/liquids.qml
View file @
1cb54afb
...
...
@@ -6,21 +6,25 @@ ListModel {
ListElement
{
name
:
"
Water
"
lcolor
:
"
blue
"
density
:
1
}
ListElement
{
name
:
"
Petrol
"
lcolor
:
"
black
"
density
:
0.8
}
ListElement
{
name
:
"
Corn S
"
lcolor
:
"
yellow
"
density
:
3
}
ListElement
{
name
:
"
Oil
"
lcolor
:
"
brown
"
density
:
0.2
}
}
...
...
qml/Example1/main.qml
View file @
1cb54afb
...
...
@@ -19,17 +19,36 @@ Rectangle {
text
:
qsTr
(
""
)
anchors.centerIn
:
parent
}
}
DropArea
{
x
:
265
;
y
:
293
width
:
116
;
height
:
125
onEntered
:
maincanvas
.
state
=
"
IconDropped
"
id
:
beakerDropArea
onDropped
:
{
drag
.
source
.
state
=
""
var
density
=
drag
.
source
.
objectMass
/
drag
.
source
.
objectVolume
var
ldensity
=
beakerArea
.
objectDensity
if
(
ldensity
>
density
)
{
namerecttext
.
text
=
"
It floats !!
"
}
else
{
namerecttext
.
text
=
"
It sinks !!
"
drag
.
source
.
sinkRate
=
(
density
/
ldensity
)
*
1000
}
drag
.
source
.
state
=
"
moved
"
}
//onEntered: maincanvas.state = Qt.new_method(1)
Rectangle
{
x
:
0
y
:
0
anchors.fill
:
parent
color
:
"
green
"
border.
color
:
"
green
"
anchors.rightMargin
:
0
anchors.bottomMargin
:
0
anchors.leftMargin
:
0
...
...
@@ -39,34 +58,6 @@ Rectangle {
}
// Image {
// id: image1
// x: 22
// y: 104
// width: 39
// height: 39
// property int weight: 100
// property string object_name : "Stone"
// source: "stone-clipart-rock-outline-md.png"
// Drag.active: dragArea.drag.active
// Drag.hotSpot.x: 10
// Drag.hotSpot.y: 10
// MouseArea {
// id : dragArea
// anchors.fill: parent
// drag.target: parent
// onClicked: maincanvas.state = "ClickedIcon"
// //onDragChanged: maincanvas.state = "ClickedIcon"
// //onReleased: parent.Drag.drop();
// }
// Component.onCompleted: {
// var apple_object = Qt.createComponent("apple_object.qml")
// var apple = apple_object.createObject(maincanvas, {"x":100, "y":100})
// //image1.source = apple_object.apple_image.source
// }
// }
Image
{
id
:
image2
...
...
@@ -80,10 +71,9 @@ Rectangle {
id
:
beakerArea
x
:
36
y
:
79
property
real
objectDensity
width
:
117
height
:
127
}
}
...
...
@@ -107,11 +97,13 @@ Rectangle {
id
:
object_image
width
:
40
height
:
40
x
:
0
y
:
0
source
:
image
property
int
objectMass
:
mass
property
int
objectVolume
:
volume
property
string
objectName
:
name
property
real
sinkRate
:
100.0
Drag.source
:
object_image
Drag.active
:
dragArea
.
drag
.
active
signal
selected
(
var
selectedObject
)
...
...
@@ -120,16 +112,29 @@ Rectangle {
anchors.fill
:
parent
drag.target
:
parent
onClicked
:
object_image
.
selected
(
name
)
onReleased
:
{
console
.
log
(
"
Hello
"
)
parent
.
Drag
.
drop
()
}
// onReleased: {
// namerecttext.text = qsTr("You have moved a " + name)
// mass_text.text = qsTr("Mass :: " +mass)
// }
}
onSelected
:
{
namerecttext
.
text
=
qsTr
(
"
You have selected a
"
+
name
)
}
}
states
:
[
State
{
name
:
"
moved
"
PropertyChanges
{
target
:
object_image
;
y
:
y
+
30
}
}
]
transitions
:
Transition
{
NumberAnimation
{
duration
:
object_image
.
sinkRate
;
properties
:
"
x,y
"
;
easing.type
:
Easing
.
InOutQuad
}
}
}
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
...
...
@@ -252,6 +257,8 @@ Rectangle {
width
:
40
height
:
40
color
:
lcolor
property
string
objectName
:
name
property
real
objectDensity
:
density
anchors.horizontalCenter
:
parent
.
horizontalCenter
signal
selected
()
MouseArea
{
...
...
@@ -259,8 +266,9 @@ Rectangle {
onClicked
:
ltype
.
selected
()
}
onSelected
:
{
namerecttext
.
text
=
"
You selected
"
+
name
namerecttext
.
text
=
"
You selected
"
+
name
+
"
Of
"
+
density
+
"
Density
"
beakerArea
.
color
=
lcolor
beakerArea
.
objectDensity
=
density
}
}
...
...
@@ -293,5 +301,6 @@ Rectangle {
}
}
]
}
qml/Example1/objects.qml
View file @
1cb54afb
...
...
@@ -6,14 +6,14 @@ ListModel {
ListElement
{
name
:
"
Apple
"
image
:
"
apple.png
"
mass
:
10
mass
:
1
3
0
volume
:
125
}
ListElement
{
name
:
"
Stone
"
image
:
"
stone.png
"
mass
:
25
mass
:
600
volume
:
343
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment