PDA

View Full Version : 2 images qt-qml app



nitin_867
3rd April 2013, 11:57
Hi All,

I am totally new in Qt development. Even not enough familiar with c++ language too :(

I am trying to develop an Qt GUI Application which have mainly two images (“Im1” & “Im2”). The main purpose of this application is to slide Im1 on Im2 based of different values of a variable (Lets say, name of variable is “Vl”)

Since i was not able to attached the exact images which am using for my application, i mentioned an illustration below:

0========================================== position at Vl=0;

=========0================================= position at Vl=2;

===================0======================= position at Vl=3;

====================================0====== position at Vl=9;

-- So basically Im1(0) has to be move on Im2(====) depending upon different values of ‘Vl’.
-- I have some changing values (ranging from 0 to 10) which i am reading from a file and i want to assign these value “Vl” variable.
-- Based on that the point(Im1) will slide on static slider(Im2)
-- The program should run continuously as i keep changing the values inside the file and thus Vl will update.
-- Here is the complete flow
a) Continuously reading values from a file —>
b) Reads one value at a time -->
c) Read value will be assigned to Vl variable -->
d) Moving Im1 based on current Vl value -->
e) This Im will move/slide horizontally every-time depending on Vl values

I went through some QML element such as Transition, translate, signal connection etc but do not have enough knowledge about using them.
Hence could anyone please suggest sample code for this. Thanks in advance.

wysota
3rd April 2013, 19:10
import QtQuick 2.0

Item {
id: root
width: 800
height: 800

Rectangle {
id: im2
width: 600
height: 50
anchors.centerIn: parent

Rectangle {
id: im1
property int vi: 0

width: 80; height: 80; radius: width/2
anchors.verticalCenter: parent.verticalCenter
x: im2.width*vi/10
PropertyAnimation on vi {
from: 0
to: 10
duration: 3000
loops: Animation.Infinite
running: true
}
}
}
}