Theme

A global object for defining app-wide styling attributes More...

Import Statement: import VPlayApps 1.0
Inherits:

Item

Properties

Methods

Detailed Description

All apps created with V-Play Apps ship with a default style which follows platform-specific attributes.

For most flexibility it's however also possible to overwrite these styles by your own. The most basic example is changing the background color of a navigation bar within a NavigationStack item.

To change a theme-able property implement the App::initTheme signal handler and overwrite the values like in this example:

 import VPlayApps 1.0

 App {
   onInitTheme: {
     // Set the navigation bar background to a shiny blue
     Theme.navigationBar.backgroundColor = "blue"

     // Set the global text color to a dark blue
     Theme.colors.textColor = "#000080"
   }
 }

Note: You can change theme-able properties at any given time from within your app's code, not only in the App::initTheme handler. The recommended approach is however to use the given handler for setting a default style at app start.

Property Documentation

appButton : ThemeAppButton

You can override sub-properties of the appButton property to set the global appearance of AppButton items.

Following properties can be overridden:


appCheckBox : ThemeAppCheckBox

You can override sub-properties of the appCheckBox property to set the global appearance of AppCheckBox items. See the documentation of the ThemeAppCheckBox type for an overview of available properties.

This QML property was introduced in V-Play 2.7.1.


[read-only] backgroundColor : color

Read-only alias for colors.backgroundColor.


boldFont : QtObject

Override this property to change the app-wide default bold font. It can either be set to a FontLoader object, or a simple QtObject with a name property, defining the used font name.

If not changed, the default font of an empty Text item is used.


colors : ThemeColors

You can override sub-properties of the colors property to change global colors for the various AppSDK controls.

Following properties can be overridden:


[read-only] controlBackgroundColor : color

Read-only alias for colors.controlBackgroundColor.

This QML property was introduced in V-Play 2.8.2.


[read-only] disabledColor : color

Read-only alias for colors.disabledColor.


[read-only] disclosureColor : color

Read-only alias for colors.disclosureColor.


[read-only] dividerColor : color

Read-only alias for colors.dividerColor.


[read-only] inputCursorColor : color

Read-only alias for colors.inputCursorColor.

This QML property was introduced in V-Play 2.7.0.


[read-only] inputSelectionColor : color

Read-only alias for colors.inputSelectionColor.

This QML property was introduced in V-Play 2.7.0.


[read-only] isAndroid : bool

Readonly property returning true if the app is currently running on an Android device.

You can use this property to change your app's style or logic depending on the underlying platform. The following example shows how to use a different navigation bar color for Android devices:

 import VPlayApps 1.0

 App {
   onInitTheme: {
     // Set the navigation bar background to a shiny blue on Android only
     Theme.navigationBar.backgroundColor = Theme.isAndroid ? "blue" : "red"
   }
 }

[read-only] isDesktop : bool

Readonly property returning true if the app is currently running on an desktop operating system, i.e. Windows, macOS (Mac OS X) or Linux.

You can use this property to change your app's style or logic depending on the underlying platform.


[read-only] isIos : bool

Readonly property returning true if the app is currently running on an iOS device.

You can use this property to change your app's style or logic depending on the underlying platform. The following example shows how to use a different navigation bar color for iOS devices:

 import VPlayApps 1.0

 App {
   onInitTheme: {
     // Set the navigation bar background to a shiny blue on iOS only
     Theme.navigationBar.backgroundColor = Theme.isIos ? "blue" : "red"
   }
 }

[read-only] isLinux : bool

Readonly property returning true if the app is currently running on a Linux operating system.

You can use this property to change your app's style or logic depending on the underlying platform. The following example shows how to use a different navigation bar color for Linux devices:

 import VPlayApps 1.0

 App {
   onInitTheme: {
     // Set the navigation bar background to a shiny blue on Linux only
     Theme.navigationBar.backgroundColor = Theme.isLinux ? "blue" : "red"
   }
 }

[read-only] isOSX : bool

Readonly property returning true if the app is currently running on a macOS (Mac OS X) operating system.

You can use this property to change your app's style or logic depending on the underlying platform. The following example shows how to use a different navigation bar color for macOS devices:

 import VPlayApps 1.0

 App {
   onInitTheme: {
     // Set the navigation bar background to a shiny blue on macOS only
     Theme.navigationBar.backgroundColor = Theme.isOSX ? "blue" : "red"
   }
 }

[read-only] isPortrait : bool

Readonly property returning whether the app is currently in portrait mode. You can use this property to change your app's style based on the interface orientation. It refers to the App::portrait property of your application.

This QML property was introduced in V-Play 2.6.2.


[read-only] isWinPhone : bool

Readonly property returning true if the app is currently running on a Windows Phone device.

You can use this property to change your app's style or logic depending on the underlying platform. The following example shows how to use a different navigation bar color for Windows Phone devices:

 import VPlayApps 1.0

 App {
   onInitTheme: {
     // Set the navigation bar background to a shiny blue on Windows Phone only
     Theme.navigationBar.backgroundColor = Theme.isWinPhone ? "blue" : "red"
   }
 }

[read-only] isWindows : bool

Readonly property returning true if the app is currently running on a Windows operating system.

You can use this property to change your app's style or logic depending on the underlying platform. The following example shows how to use a different navigation bar color for Windows devices:

 import VPlayApps 1.0

 App {
   onInitTheme: {
     // Set the navigation bar background to a shiny blue on Windows only
     Theme.navigationBar.backgroundColor = Theme.isWindows ? "blue" : "red"
   }
 }

listItem : ThemeSimpleRow

You can override sub-properties of the listItem property to set the default appearance of SimpleRow list items. These items are the default component for ListView::delegate when using a ListPage.

The following properties can be overridden:

This QML property was introduced in V-Play 2.6.2.


listSection : ThemeSimpleSection

You can override sub-properties of the listSection property to set the default appearance of ListView sections based on the SimpleSection type. This component is the default type for ListView::section.delegate when using a ListPage.

See the documentation of the ThemeSimpleSection type for an overview of available properties.

This QML property was introduced in V-Play 2.6.2.


listSectionCompact : ThemeSimpleSection

You can override sub-properties of the listSectionCompact property to set the default appearance of ListView sections based on the SimpleSection type, if SimpleSection::style.compactStyle is set to true.

See the documentation of the ThemeSimpleSection type for an overview of available properties.

This QML property was introduced in V-Play 2.6.2.


You can override sub-properties of the navigationAppDrawer property to set the global appearance of Navigation's AppDrawer items.

Following properties can be overridden:

  • navigationAppDrawer.backgroundColor: The background color of the app drawer.
  • navigationAppDrawer.textColor: The text color of the text in the row.
  • navigationAppDrawer.activeTextColor: The text color of the text in the row when the item is active.
  • navigationAppDrawer.rowSpacing: The spacing on top and bottom of the text labels within the row.
  • navigationAppDrawer.dividerHeight: The height of the row divider line.
  • navigationAppDrawer.dividerColor: The color of the row divider line.
  • navigationAppDrawer.itemBackgroundColor: The background color of the navigation items.
  • navigationAppDrawer.itemSelectedBackgroundColor: The background color of a selected item.

This QML property was introduced in V-Play 2.6.1.


You can override sub-properties of the navigationBar property to set the global appearance of NavigationBar items (e.g. within a NavigationStack).

Following properties can be overridden:

  • navigationBar.titleColor: The title color defines the font color of the displayed title label.
  • navigationBar.backgroundColor: The background color fills the NavigationBar's background.
  • navigationBar.dividerColor: The divider is displayed as a thin line at the very bottom of the navigation bar. Override the divider color to customize the look of the divider.
  • navigationBar.itemColor: The item color defines the NavigationBar's left and right item color. By default this property matches the title's color.
  • navigationBar.titleTextFont: Specifies the font for the NavigationBar's title text.
  • navigationBar.titleTextSize: Size of the title text, in pixels.
  • navigationBar.titleTextBold: Whether the title text is displayed bold.
  • navigationBar.titleAlignLeft: Whether the title should be left aligned.
  • navigationBar.titleAlignBottom: Whether the title should be bottom aligned.
  • navigationBar.titleLeftMargin: Adds an additional margin to the left of the navigationBar's title item if it is left-aligned.
  • navigationBar.titleBottomMargin: Specifies a margin from the bottom of the navigation bar to the title text, unless the text is vertically centered.
  • navigationBar.height: Height of the navigation bar, in pixels.
  • navigationBar.defaultBarItemPadding: Default left and right padding of NavigationBarItems.
  • navigationBar.defaultIconSize: Default size of icons in the navigation bar.

normalFont : QtObject

Override this property to change the app-wide default font. It can either be set to a FontLoader object, or a simple QtObject with a name property, defining the used font name.

If not changed, the default font of an empty Text item is used.


[read-only] placeholderTextColor : color

Read-only alias for colors.placeholderTextColor.


platform : string

This property contains a string representing the current platform the app runs on.

It can also be changed to simulate running on a different platform, for testing purposes.

It has one of the following values:

  • "android"
  • "ios"
  • "winphone"
  • "linux"
  • "osx"
  • "windows"

[read-only] secondaryBackgroundColor : color

Read-only alias for colors.secondaryBackgroundColor.

This QML property was introduced in V-Play 2.6.2.


[read-only] secondaryTextColor : color

Read-only alias for colors.secondaryTextColor.


[read-only] selectedBackgroundColor : color

Read-only alias for colors.selectedBackgroundColor.

This QML property was introduced in V-Play 2.6.2.


[read-only] statusBarHeight : int

Read-only property to retrieve the status bar height of the device, in pixels. If the status bar is hidden, 0 is returned.

This QML property was introduced in V-Play 2.6.1.


[read-only] statusBarStyle : int

Read-only alias for colors.statusBarStyle.


tabBar : ThemeTabControl

You can override sub-properties of the tabBar property to set the global appearance of tabs created with Navigation, TabControl or AppTabBar.

Following properties can be overridden:

  • tabBar.titleColor: The title color defines the font color of the currently selected title label and the icon. Only applies for main-tabs based on NavigationItem.
  • tabBar.titleOffColor: The off color defines the font color of the title label and the icon tabs that are not selected. Only applies for main-tabs based on NavigationItem.
  • tabBar.subTabTitleColor: The title color defines the font color of the currently selected title label and the icon. Only applies for sub-tabs based on AppTabButton.
  • tabBar.subTabTitleOffColor: The off color defines the font color of the title label and the icon of tabs that are not selected. Only applies for sub-tabs based on AppTabButton.
  • tabBar.backgroundColor: The background color fills the TabControl's background.
  • tabBar.dividerColor: The divider is displayed as a thin line at the very top of the tab bar. Override the divider color to customize the look of the divider.
  • tabBar.height: Height of the tab bar.
  • tabBar.iconSize: The size of the tab icons used for the tab bar.
  • tabBar.showIcon: Whether the specified icon should be shown within a tab.
  • tabBar.textSize: The size of the title displayed for each tab. Only applies for main-tabs based on NavigationItem.
  • tabBar.subTabTextSize: The size of the title displayed for each tab. Only applies for sub-tabs based on AppTabButton.
  • tabBar.fontCapitalization: The Text::font.capitalization setting of the title-
  • tabBar.fontBold: Whether the tab title is displayed bold.
  • tabBar.textMaximumLineCount: The Maximum line count for the title text of each tab.
  • tabBar.markerColor: The color of the bottom line that marks the active tab on Android.

[read-only] textColor : color

Read-only alias for colors.textColor.


[read-only] tintColor : color

Read-only alias for colors.tintColor.


Method Documentation

reset()

Reset the default Theme. This discards any changes made to the Theme.


Videos

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support