Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QML Flickable Element

The Flickable item provides a surface that can be "flicked". More...

Inherits Item

Inherited by GridView and ListView.

This element was introduced in Qt 4.7.

Properties

Signals

Methods

Detailed Description

The Flickable item places its children on a surface that can be dragged and flicked, causing the view onto the child items to scroll. This behavior forms the basis of Items that are designed to show large numbers of child items, such as ListView and GridView.

In traditional user interfaces, views can be scrolled using standard controls, such as scroll bars and arrow buttons. In some situations, it is also possible to drag the view directly by pressing and holding a mouse button while moving the cursor. In touch-based user interfaces, this dragging action is often complemented with a flicking action, where scrolling continues after the user has stopped touching the view.

Flickable does not automatically clip its contents. If it is not used as a full-screen item, you should consider setting the clip property to true.

Example Usage

The following example shows a small view onto a large image in which the user can drag or flick the image in order to view different parts of it.

 import QtQuick 1.0

 Flickable {
     width: 200; height: 200
     contentWidth: image.width; contentHeight: image.height

     Image { id: image; source: "bigImage.png" }
 }

Items declared as children of a Flickable are automatically parented to the Flickable's contentItem. This should be taken into account when operating on the children of the Flickable; it is usually the children of contentItem that are relevant. For example, the bound of Items added to the Flickable will be available by contentItem.childrenRect

Limitations

Note: Due to an implementation detail, items placed inside a Flickable cannot anchor to it by id. Use parent instead.

Property Documentation

read-onlyatXBeginning : bool

read-onlyatXEnd : bool

read-onlyatYBeginning : bool

read-onlyatYEnd : bool

These properties are true if the flickable view is positioned at the beginning, or end respecively.


boundsBehavior : enumeration

This property holds whether the surface may be dragged beyond the Fickable's boundaries, or overshoot the Flickable's boundaries when flicked.

This enables the feeling that the edges of the view are soft, rather than a hard physical boundary.

The boundsBehavior can be one of:

  • Flickable.StopAtBounds - the contents can not be dragged beyond the boundary of the flickable, and flicks will not overshoot.
  • Flickable.DragOverBounds - the contents can be dragged beyond the boundary of the Flickable, but flicks will not overshoot.
  • Flickable.DragAndOvershootBounds (default) - the contents can be dragged beyond the boundary of the Flickable, and can overshoot the boundary when flicked.

read-onlycontentItem : Item

The internal item that contains the Items to be moved in the Flickable.

Items declared as children of a Flickable are automatically parented to the Flickable's contentItem.

Items created dynamically need to be explicitly parented to the contentItem:

 Flickable {
     id: myFlickable
     function addItem(file) {
         var component = Qt.createComponent(file)
         component.createObject(myFlickable.contentItem);
     }
 }

contentWidth : real

contentHeight : real

The dimensions of the content (the surface controlled by Flickable). This should typically be set to the combined size of the items placed in the Flickable.

The following snippet shows how these properties are used to display an image that is larger than the Flickable item itself:

 import QtQuick 1.0

 Flickable {
     width: 200; height: 200
     contentWidth: image.width; contentHeight: image.height

     Image { id: image; source: "bigImage.png" }
 }

In some cases, the the content dimensions can be automatically set using the childrenRect.width and childrenRect.height properties.


contentX : real

contentY : real

These properties hold the surface coordinate currently at the top-left corner of the Flickable. For example, if you flick an image up 100 pixels, contentY will be 100.


flickDeceleration : real

This property holds the rate at which a flick will decelerate.

The default value is platform dependent.


flickableDirection : enumeration

This property determines which directions the view can be flicked.

  • Flickable.AutoFlickDirection (default) - allows flicking vertically if the contentHeight is not equal to the height of the Flickable. Allows flicking horizontally if the contentWidth is not equal to the width of the Flickable.
  • Flickable.HorizontalFlick - allows flicking horizontally.
  • Flickable.VerticalFlick - allows flicking vertically.
  • Flickable.HorizontalAndVerticalFlick - allows flicking in both directions.

read-onlyflicking : bool

read-onlyflickingHorizontally : bool

read-onlyflickingVertically : bool

These properties describe whether the view is currently moving horizontally, vertically or in either direction, due to the user flicking the view.


read-onlyhorizontalVelocity : real

read-onlyverticalVelocity : real

The instantaneous velocity of movement along the x and y axes, in pixels/sec.

The reported velocity is smoothed to avoid erratic output.


interactive : bool

This property describes whether the user can interact with the Flickable. A user cannot drag or flick a Flickable that is not interactive.

By default, this property is true.

This property is useful for temporarily disabling flicking. This allows special interaction with Flickable's children; for example, you might want to freeze a flickable map while scrolling through a pop-up dialog that is a child of the Flickable.


maximumFlickVelocity : real

This property holds the maximum velocity that the user can flick the view in pixels/second.

The default value is platform dependent.


read-onlymoving : bool

read-onlymovingHorizontally : bool

read-onlymovingVertically : bool

These properties describe whether the view is currently moving horizontally, vertically or in either direction, due to the user either dragging or flicking the view.


pressDelay : int

This property holds the time to delay (ms) delivering a press to children of the Flickable. This can be useful where reacting to a press before a flicking action has undesirable effects.

If the flickable is dragged/flicked before the delay times out the press event will not be delivered. If the button is released within the timeout, both the press and release will be delivered.

Note that for nested Flickables with pressDelay set, the pressDelay of inner Flickables is overridden by the outermost Flickable.


read-onlyvisibleArea.xPosition : real

read-onlyvisibleArea.widthRatio : real

read-onlyvisibleArea.yPosition : real

read-onlyvisibleArea.heightRatio : real

These properties describe the position and size of the currently viewed area. The size is defined as the percentage of the full view currently visible, scaled to 0.0 - 1.0. The page position is usually in the range 0.0 (beginning) to 1.0 minus size ratio (end), i.e. yPosition is in the range 0.0 to 1.0-heightRatio. However, it is possible for the contents to be dragged outside of the normal range, resulting in the page positions also being outside the normal range.

These properties are typically used to draw a scrollbar. For example:

 Rectangle {
     width: 200; height: 200

     Flickable {
         id: flickable
         ...
     }

     Rectangle {
         id: scrollbar
         anchors.right: flickable.right
         y: flickable.visibleArea.yPosition * flickable.height
         width: 10
         height: flickable.visibleArea.heightRatio * flickable.height
         color: "black"
     }
 }

See also scrollbar example.


Signal Documentation

Flickable::onFlickEnded ()

This handler is called when the view stops moving due to a flick.


Flickable::onFlickStarted ()

This handler is called when the view is flicked. A flick starts from the point that the mouse or touch is released, while still in motion.


Flickable::onMovementEnded ()

This handler is called when the view stops moving due to user interaction. If a flick was generated, this handler will be triggered once the flick stops. If a flick was not generated, the handler will be triggered when the user stops dragging - i.e. a mouse or touch release.


Flickable::onMovementStarted ()

This handler is called when the view begins moving due to user interaction.


Method Documentation

Flickable::resizeContent ( real width, real height, QPointF center )

This documentation is under development and is subject to change.

Resizes the content to width x height about center.

This does not scale the contents of the Flickable - it only resizes the contentWidth and contentHeight.

Resizing the content may result in the content being positioned outside the bounds of the Flickable. Calling returnToBounds() will move the content back within legal bounds.

This documentation was introduced in QtQuick 1.1.


Flickable::returnToBounds ()

This documentation is under development and is subject to change.

Ensures the content is within legal bounds.

This may be called to ensure that the content is within legal bounds after manually positioning the content.

This documentation was introduced in QtQuick 1.1.


Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.7
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web