1

I have a small problem with qml code on how to display a dicitonary. On the python side I just have to declare it as QVariantMap

from PySide2.QtCore import QObject, Signal
  
saved = Signal("QVariantMap")

I have managed to connect the signal well, and if i know the keys of the dictionary in advance i can display it well if I initialize it as property variant and then for example write saved["a"]

property variant saved: {"a": 0.0, "b": 0.0, "c": 0.0, "d": 0.0};

however my signal might come with less keys than the total. let's say it comes with keys "a" and "b". and I don't know in advance which keys (of the 4 total) will be in the signal. is there a way in qml to loop through its keys and then display their values??

The qt version I use is QtQuick 2.12

Thank you if you have a tip!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
EricD1990
  • 33
  • 1
  • 5
  • 3
    It should be a normal Javascript object by that point so this answer should work for you: https://stackoverflow.com/questions/684672/how-do-i-loop-through-or-enumerate-a-javascript-object – David K. Hess Mar 01 '22 at 16:24

0 Answers0