Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-82665

[Qt6] Static QML properties and functions

    XMLWordPrintable

Details

    Description

      • Static properties and functions can be implicitly shared and their common binding expression will be evaluated only once.
      • Inherited properties should be allowed to be made static and implicitly shared as well. This provides benefits that the current singleton pattern does not.
      • Static functions can be offloaded in a JS library or another QML object. However by using static functions code homogeneity is increased by keeping related code in the same place.
      Possible Syntax
      component MySprite: Image{
       required x
       required y
       static height: 100
       static width: 100
       
       static function doCollide( s1:MySprite, s2:MySprite) {
        return Math.abs(s1.x-s2.x)<MySprite.width && Math.abs(s1.y-s2.y)<MySprite.height;
       }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            adrian.gabureanu Adrian Gabureanu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes