Sur cette page

placeAttribute QML Value Type

Le type `placeAttribute` contient des informations génériques sur les attributs de lieu. En savoir plus...

Import Statement: import QtLocation 6.12
Since: QtLocation 5.5

Propriétés

Description détaillée

Un attribut « place » stocke une information supplémentaire concernant une « Place » qui n’est pas autrement exposée via le type « Place ». Un « placeAttribute » est une donnée textuelle, accessible via la propriété « text » et une « label ». Les propriétés « l {placeAttribute::}{text} » et « label » sont toutes deux destinées à être affichées à l’utilisateur. Les « placeAttributes » sont stockés dans une table « ExtendedAttributes » avec une clé unique.

L'exemple suivant montre comment afficher tous les attributs dans une liste :

import QtQuick
import QtPositioning
import QtLocation

ListView {
    model: place.extendedAttributes.keys()
    delegate: Text {
        text: "<b>" + place.extendedAttributes[modelData].label + ": </b>" +
              place.extendedAttributes[modelData].text
    }
}

L'exemple suivant montre comment attribuer et modifier un attribut :

    //assign a new attribute to a place
    var smokingAttrib = Qt.createQmlObject('import QtLocation; PlaceAttribute {}', place);
    smokingAttrib.label = "Smoking Allowed"
    smokingAttrib.text = "No"
    place.extendedAttributes.smoking = smokingAttrib;

    //modify an existing attribute
    place.extendedAttributes.smoking.text = "Yes"

Documentation sur les propriétés

label : string

Cette propriété contient l'étiquette de l'attribut, qui est une chaîne de caractères visible par l'utilisateur et décrivant l'attribut.

text : string

Cette propriété contient l'attribut « text », qui permet d'afficher des informations supplémentaires sur le lieu.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.