User Tools

Site Tools


qt-quick-for-designers-1:qt_quick_and_javascript

This is an old revision of the document!


Qt Quick and Javascript

  • Qt Quick lists elements with properties, and JavaScript allows you to express more complex behavior than static values.
Item {
  id: label1
  x: 80
  width: 100
  height: 100
 
  Image {
    source: {
      if(pressed) {
        return "img2.png";
      } else {
        return "img1.png";
      }
    }
  }
}
  • You can add a Javascript function anywhere in your Qt Quick file.
  • This is a simple function that picks a number and references it in an array of states.
function randomState()
{
  var statesArray = ["topLeft", "topRight", "bottomLeft", "bottomRight"];
  var randomNumber = Math.floor(Math.random()*statesArray.length);
  return statesArray[randomNumber];
}
qt-quick-for-designers-1/qt_quick_and_javascript.1371871639.txt.gz · Last modified: 2013/06/22 03:27 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki