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

Suggestion: export / alias all properties of wrapped control

    XMLWordPrintable

Details

    Description

      User contacted Qt support with following improvement idea:

      "

      In order to style my controls, i have wrapped some of theme in My... components (e.g TextField MyTextField)

      Problem is that I need to alias by hand all properties of the wrapped TextField by hand.

      So, conceptually

      MyTextField {
          
          // can this list be made more simple ?
          property alias text : field.text
          property alias elide : field.elide
          // etc
          
          RowLayout {
              Image{
              }
              TextField {
                  id : field
              }
          }

      "

       

      Users improvement idea:

      "

      Perhaps something similar to the default property ?

      property default alias : componentId
                               
      //eg.
      
      Item {
          
          // would alias all properties of subItem
          property default alias : subItem
          
          Text {
              id : subItem
          }
      }

      perhaps one could consider 'merging' where the last alias overrules any alias
      property previously aliased ?

      Item {
          
          // would alias all properties of subItem1
          property default alias : subItem1
          // this alias exports all properties of subitem2 overruling any previous
          aliases ? (i.e. subitem1 has no valid aliases anymore as both are Text Items
          property default alias : subItem2
          // perhaps also allowing this : overrule subItem2 text alias cause all
          alliases that are NOT text to be subitem2 but only text to be subitem1
          property alias text : subItem1.text
          
          Text {
              id : subItem1
          }
          Text {
              id : subItem2
          }
      }
      
      

      perhaps with an unalias which would break the alias of default exported
      aliases

      Item {
          
          // would alias all properties of subItem1
          property default alias : subItem1
          // breaks the alias for subitem1.text
          property unalias : subItem1.text
          
          Text {
              id : subItem1
          }
      }

      or allow for multiple aliases (e.g set all colors of items

      Item {
          property alias color : [ r1.color, r2.color ]
          
          Rectangle {
              id : r1
          }
          Rectangle {
              id : r2
          }
      }

      "

      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
            tero.pelkonen Tero Pelkonen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes