[Interest] How to provide a component to a QML item?

Jérôme Godbout jerome at bodycad.com
Tue Jan 3 15:39:39 CET 2017


StandardScreenWithSpecificContent
{
  id: component_
  property var myOptions: ['foo', 'bar']
  property alias delegate: repeater_.delegate

   Repeater
   {
       id: repeater_
       model: component_.myOptions
       delegate: StandardScreenContent
       {
          property string myContent: component_.myOptions[index]
          // use a Loader if you need dynamic instance of children with
component_ input or even Instantiator for non Item object
        }
   }
}

[image: bodycad] <https://www.bodycad.com/>
Jerome Godbout
Software Developer
2035 rue du Haut-Bord, Québec, QC, Canada. G1N 4R7
T:  +1 418 527-1388
E: jerome at bodycad.com
www.bodycad.com

The contents of this email message and any attachments are intended solely
for the addressee(s) and may contain confidential and/or privileged
information and may be legally protected from disclosure. If you are not
the intended recipient of this message or their agent, or if this message
has been addressed to you in error, please immediately alert the sender by
reply email and then delete this message and any attachments. If you are
not the intended recipient, you are hereby notified that any use,
dissemination, copying, or storage of this message or its attachments is
strictly prohibited.

Le contenu de ce message et les pièces jointes sont destinés uniquement
pour le(s) destinataire(s) et peuvent contenir des informations
confidentielles et / ou privilégiées qui peuvent être protégées légalement
contre toute divulgation. Si vous n'êtes pas le destinataire de ce message
ou son agent, ou si ce message vous a été adressé par erreur, s’il vous
plaît avertir immédiatement l'expéditeur par courriel de réponse, puis
supprimer ce message et les pièces jointes. Si vous n'êtes pas le
destinataire prévu, vous êtes par la présente informé que toute
utilisation, diffusion, copie, ou stockage de ce message ou de ses pièces
jointes est strictement interdit.

On Mon, Dec 19, 2016 at 8:16 PM, Yasser Sobhy <yasser.sobhy.net at gmail.com>
wrote:

> Hi Jason
>
> I am not sure if I have understood you correctly, but I think I have used
> a similar approach in some of my apps to create a dynamic-content list.
>
> I have done that by aliasing the data property of the column item as
> follows
>
> //StandardScreenWithSpecificContent.qml
> StandardScreenWithSpecificContent {
>
> property alias elements : column1.data
>
>    /* implied StandardScreenContent */
>      Column {
>          id: column1
>      }
> }
>
> This way you can dynamically change the children items of the column by
> assigning an array of items
>
>
> StandardScreenWithSpecificContent {
>       elements : [
>           Label {
>                  text: "label 1"
>            },
>
>             Label {
>                  text: "label 2"
>            }
>       ]
> }
>
>
>
> On Dec 20, 2016 3:30 AM, "Jason H" <jhihn at gmx.com> wrote:
>
> I've got a situation where I have a variety of items ("screens" in a
> stackView) where they have a similar structure, but the content differs.
>
> Example:
> Screen {
>   Column {
>     StandardScreenContent { }
>     ScreenSpecificContent{ }
>   }
> }
>
> But I'd like to do it like:
> StandardScreenWithSpecificContent {
>    /* implied StandardScreenContent */
>    delegate: {
>      Column {
>        /* screen specific content*/
>      }
>    }
> }
>
> This is a limited example, so it may not make a lot of sense in this
> context but I think that illustrates my intent. How can I accomplish it?
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170103/7e19b8b1/attachment.html>


More information about the Interest mailing list