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

QML should allow the declaration of private properties

    XMLWordPrintable

Details

    Description

      As a QML component developper, I often need private properties, that are needed for my component to work, but that should not be eexposed to the component user.

      For example :

      MyTextInput.qml
      import Qt 4.7
      
      TextInput {
      	signal endEditing(bool changed)
      
      	property string oldText		//I'd like to make this private
      
      	/*					// Workaround
      	QtObject {
      		id: privateVars
      		property string oldText
      	}
      	*/
      
      	onFocusChanged: {
      		if (focus) {
      			oldText = text;
      		} else {
      			if (text != oldText)
      				endEditing(true);
      			else
      				endEditing(false);
      		}
      	}
      
      }
      

      So I'd suggest that it would be helpful if we had a way to mark a property as private.

      I discussed about that on #qt-qml and Michael Brasser suggested:

      we've also discussed this in the past in the Brisbane office; one unresolved question has been what exactly private should mean – obviously it means inaccessible to users of the component, but what about sub-components of the component, etc? If there isn't already something in JIRA for it, I'd suggest adding it, and we can look into more for a future release. Your workaround is exactly what we suggest at the moment

      Attachments

        Issue Links

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

          Activity

            People

              qtqmlteam Qt Qml Team User
              gregschlom Gregory Schlomoff
              Votes:
              27 Vote for this issue
              Watchers:
              30 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes