ExpressionRole

A custom role computed from a javascript expression. More...

Import Statement: import VPlayApps 1.0
Since: V-Play 2.18.1
Inherits:

ProxyRole

Properties

Detailed Description

An ExpressionRole is a ProxyRole allowing to implement a custom role based on a javascript expression.

In the following example, the c role is computed by adding the a role and b role of the model :

 SortFilterProxyModel {
    sourceModel: numberModel
    proxyRoles: ExpressionRole {
        name: "c"
        expression: model.a + model.b
   }
 }

Property Documentation

expression : expression

An expression to implement a custom role. It has the same syntax has a Property Binding except it will be evaluated for each of the source model's rows. The data for this role will be the retuned valued of the expression. Data for each row is exposed like for a delegate of a QML View.

This expression is reevaluated for a row every time its model data changes. When an external property (not index or in model) the expression depends on changes, the expression is reevaluated for every row of the source model. To capture the properties the expression depends on, the expression is first executed with invalid data and each property access is detected by the QML engine. This means that if a property is not accessed because of a conditional, it won't be captured and the expression won't be reevaluted when this property changes.

A workaround to this problem is to access all the properties the expressions depends unconditionally at the beggining of the expression.


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