User Tools

Site Tools


qt-quick-for-designers-1:positioning_elements

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
qt-quick-for-designers-1:positioning_elements [2013/06/21 23:39] – [Absolute positioning] mithatqt-quick-for-designers-1:positioning_elements [2013/07/06 22:52] (current) mithat
Line 2: Line 2:
  
 ===== Absolute positioning ===== ===== Absolute positioning =====
-    * You can define the item's position and size relative to its parent:+{{youtube>sgQbKeIGf5M?small}}
  
 +    * You can define an item's position and size within its parent.
 <file javascript basic-positioners.qml> <file javascript basic-positioners.qml>
 import QtQuick 1.0 import QtQuick 1.0
Line 12: Line 13:
  
     Image {     Image {
 +        anchors.fill: parent
         source: "images/background.png"         source: "images/background.png"
     }     }
  
-    Spaceship {+    Image {
         id: spaceship         id: spaceship
-        x50 +        source"images/spaceship.png" 
-        y60+        anchors.verticalCenterparent.verticalCenter 
 +        anchors.horizontalCenter: parent.horizontalCenter
     }     }
 }</file> }</file>
  
 ===== Relative positioning ===== ===== Relative positioning =====
 +{{youtube>2BpsjJmhmH0?small}}
   * **Anchors** provide a way to position an item by specifying its relationship with other items.   * **Anchors** provide a way to position an item by specifying its relationship with other items.
 <file javascript anchors-positioners.qml> <file javascript anchors-positioners.qml>
Line 42: Line 46:
     }     }
 }</file> }</file>
 +==== Multiple items ====
 +{{youtube>fNOgIexwe2w?small}}
   * Many ways to specify how an item is related to another:   * Many ways to specify how an item is related to another:
     * ''anchors.right'', ''anchors.rightMargin'' ...     * ''anchors.right'', ''anchors.rightMargin'' ...
Line 56: Line 62:
     }     }
  
-    Spaceship {+    Image {
         id: spaceship         id: spaceship
 +        source: "images/spaceship.png"
         anchors.verticalCenter: parent.verticalCenter         anchors.verticalCenter: parent.verticalCenter
         anchors.horizontalCenter: parent.horizontalCenter         anchors.horizontalCenter: parent.horizontalCenter
     }     }
  
-    Spaceship {+    Image {
         id: anotherSpaceship         id: anotherSpaceship
 +        source: "images/spaceship.png"
         scale: 0.5         scale: 0.5
 +        smooth: true
         anchors.top: spaceship.bottom         anchors.top: spaceship.bottom
         anchors.right: spaceship.right         anchors.right: spaceship.right
         anchors.rightMargin: 100         anchors.rightMargin: 100
     }     }
-}</file>+} 
 +</file>
  
 +====== Resources ======
 +  * {{:qt-quick-for-designers-1:images.zip|}}
 +  * All source code is subject to this [[copyright header|copyright]].
qt-quick-for-designers-1/positioning_elements.1371857985.txt.gz · Last modified: 2013/06/21 23:39 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki