[Interest] Modify object list in qml

Oleg Evseev ev.mipt at gmail.com
Wed Nov 29 21:06:41 CET 2017


Nice. Thanks Jérôme!

2017-11-29 23:00 GMT+03:00 Jérôme Godbout <jerome at bodycad.com>:

> model: (myCondition ? [0] : []).concat(DB.getList())
>
> Take care:
> DB.getList().concat([...])
> will not work you would need to convert the QList to JS array first
>
> [image: bodycad] <https://www.bodycad.com/>
> Jerome Godbout
> Software Developer
> 2035 rue du Haut-Bord, Québec, QC, Canada. G1N 4R7
> <https://maps.google.com/?q=2035+rue+du+Haut-Bord,+Qu%C3%A9bec,+QC,+Canada.+G1N+4R7&entry=gmail&source=g>
> 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 Wed, Nov 29, 2017 at 2:41 PM, Oleg Evseev <ev.mipt at gmail.com> wrote:
>
>> Hi all,
>>
>> I would like to push an empty object in front of objects list model of
>> ComboBox.
>> I can do this in c++:
>>
>> QList<QObject*> SomeClass::getList() {
>>     QList<QObject*> list = db.getList();
>>     list.push_front(Q_NULLPTR);
>>     return list;
>> }
>>
>> then set it as model for ComboBox:
>>
>>     model: SomeClass.getList()
>>
>> And it works, I then can check modelData for null in delegate.
>>
>> But I'm interesting if there is any way I could do it in qml, something
>> like:
>>
>>   model: [0, (or undifined), DB.getList()]
>> or
>>   model: {0, (or undifined), DB.getList()}
>>
>> or push empty object in front of list in Component.onCompleted?
>>
>> Thanks in advance for help!
>>
>> --
>> With regards, Oleg.
>>
>> _______________________________________________
>> 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/20171129/d7353ea0/attachment.html>


More information about the Interest mailing list