Qt Reference Documentation

Presenting Data with QML

Introduction

Qt Quick contains a set of standard items that can be used to present data in a number of different ways. For simple user interfaces, Repeaters can be used in combination with Positioners to obtain pieces of data and arrange them in a user interface. However, when large quantities of data are involved, it is often better to use models with the standard views since these contain many built-in display and navigation features.

Views

Views are scrolling containers for collections of items. They are feature-rich, supporting many of the use cases found in typical applications, and can be customized to meet requirements on style and behavior.

A set of standard views are provided in the basic set of Qt Quick graphical elements:

  • ListView arranges items in a horizontal or vertical list
  • GridView arranges items in a grid within the available space
  • PathView arranges items on a path

Unlike these items, WebView is not a fully-featured view item, and needs to be combined with a Flickable item to create a view that performs like a Web browser.

ListView

ListView shows a classic list of items with horizontal or vertical placing of items.

The following example shows a minimal ListView displaying a sequence of numbers (using an integer as a model). A simple delegate is used to define an items for each piece of data in the model.


 import Qt 4.7

 ListView {
     width: 50; height: 200
     model: 4
     delegate: Text {
         text: index;
         font.pixelSize: 40
     }
 }

GridView

GridView displays items in a grid like an file manager's icon view.

PathView

PathView displays items on a path, where the selection remains in the same place and the items move around it.

Decorating Views

Headers and Footers

Sections

Navigation

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.

Further Reading

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.