qt-quick-for-designers-1:interaction_basics
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
qt-quick-for-designers-1:interaction_basics [2013/06/21 21:27] – created; split off from "Layout and Interaction" mithat | qt-quick-for-designers-1:interaction_basics [2013/07/06 22:52] (current) – mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Interaction | + | ====== Interaction |
===== Mouse Events ===== | ===== Mouse Events ===== | ||
* The **MouseArea** item handles mouse events for items that are on the scene. | * The **MouseArea** item handles mouse events for items that are on the scene. | ||
- | * They can emit signals which are used to specify behaviors. | + | * They can emit //signals//, which are used to specify behaviors. |
<file javascript mousearea-example.qml> | <file javascript mousearea-example.qml> | ||
import QtQuick 1.0 | import QtQuick 1.0 | ||
Line 76: | Line 76: | ||
===== Key Events ===== | ===== Key Events ===== | ||
+ | ==== Key Focus ==== | ||
+ | * You can generate a key event when a key is pressed. | ||
+ | * Example uses '' | ||
+ | <file javascript focusscope-event.qml> | ||
+ | import QtQuick 1.0 | ||
+ | |||
+ | Rectangle { | ||
+ | color: " | ||
+ | width: 240 | ||
+ | height: 25 | ||
+ | |||
+ | Text { | ||
+ | id: myText | ||
+ | text: "Press A, B or C" | ||
+ | } | ||
+ | |||
+ | Item { | ||
+ | id: keyHandler | ||
+ | focus: true | ||
+ | Keys.onPressed: | ||
+ | if (event.key == Qt.Key_A) | ||
+ | | ||
+ | else if (event.key == Qt.Key_B) | ||
+ | | ||
+ | else if (event.key == Qt.Key_C) | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | }</ | ||
+ | |||
+ | ==== Key Navigation ==== | ||
+ | * It is common in key-based UIs to use arrow keys to navigate between focused items. | ||
+ | * Example below creates a 2x2 Grid item containing four Rectangles. KeyNavigation is used to change the focus as appropriate. | ||
+ | <file javascript key-navigation.qml> | ||
+ | import QtQuick 1.0 | ||
+ | |||
+ | Grid { | ||
+ | | ||
+ | | ||
+ | | ||
+ | id: item1 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | | ||
+ | id: item2 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | | ||
+ | id: item3 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | | ||
+ | id: item4 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | | ||
+ | |||
+ | ===== Flickable ===== | ||
+ | |||
+ | * Elements placed in a Flickable item can be dragged and flicked. | ||
+ | <file javascript flickable-area.qml> | ||
+ | import QtQuick 1.0 | ||
+ | |||
+ | Flickable { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Image { | ||
+ | id: image; | ||
+ | | ||
+ | } | ||
+ | | ||
+ | * More about Flickable on the [[https:// | ||
+ | |||
+ | ====== Resources ====== | ||
+ | * {{: | ||
+ | * All source code is subject to this [[copyright header|copyright]]. | ||
qt-quick-for-designers-1/interaction_basics.1371850058.txt.gz · Last modified: 2013/06/21 21:27 by mithat