API Documentation

Documentation for developing SailfishOS applications

ViewPlaceholder QML Type

Shows a Sailfish-style fullscreen placeholder for an empty view More...

Import Statement: import Sailfish.Silica 1.0

Properties

Detailed Description

A ViewPlaceholder is a fullscreen display that is shown to avoid displaying a blank page when the page content is unavailable.

It displays the specified text and hintText in the centre of the page to provide more information about the empty content state. If the view has an associated PullDownMenu, tapping on the ViewPlaceholder text will peek at the menu to indicate to the user that options may be available in the menu.

An example:

 import QtQuick 2.2
 import Sailfish.Silica 1.0

 ApplicationWindow {
     initialPage: Component {
         Page {
             SilicaListView {
                 id: view
                 anchors.fill: parent
                 header: PageHeader { title: "Example" }
                 model: ListModel { id: listModel }

                 delegate: BackgroundItem {
                     width: ListView.view.width
                     Label {
                         text: model.date
                         x: Theme.horizontalPageMargin
                         anchors.verticalCenter: parent.verticalCenter
                     }
                 }

                 ViewPlaceholder {
                     enabled: view.count == 0
                     text: "No items yet"
                     hintText: "Pull down to add items"
                 }

                 PullDownMenu {
                     MenuItem {
                         text: "Add item"
                         onClicked: {
                             listModel.append({"date": new Date().toLocaleTimeString()})
                         }
                     }
                 }
             }
         }
     }
 }

Note: A ViewPlaceholder must have a flickable Silica type in its parent hierarchy, such as a SilicaFlickable, SilicaListView, SilicaGridView or SilicaWebView.

Property Documentation

enabled : bool

Setting enabled to true displays the placeholder text.


hintText : string

Additional text placed below the main text to hint to the user as to how the empty state can be resolved.


leftMargin : real

The margins between the left and right edges of the placeholder and its contents. The default value is Theme.horizontalPageMargin.


rightMargin : real

The margins between the left and right edges of the placeholder and its contents. The default value is Theme.horizontalPageMargin.


text : string

The placeholder text to display.


textFormat : real

The format of the displayed text and hintText. The default value is Text.PlainText.


verticalOffset : real

Offset from the center of the screen to display the text.


We use cookies to improve your user experience and to help us to develop our services. By continuing to browse the site, you approve of our use of cookies.