[Qt-interest] QHash vs python dictionary

M. Bashir Al-Noimi mbnoimi at gmx.com
Tue May 25 15:07:13 CEST 2010


Hi

On 25/05/2010 11:16 ص, Andre Somers wrote:
> On 25-5-2010 11:59, M. Bashir Al-Noimi wrote:
>>
>> Hi All,
>>
>> Currently I'm learning python for web developing. During my study I 
>> leaned about python dictionary 
>> <http://en.wikibooks.org/wiki/Python_Programming/Dictionaries> which 
>> is very flexible data structure where C++ missed it, but I found that 
>> QHash (and QMap) class is similar to it, is it true?
>>
>>
>> On another side, python dictionary defines dynamic dimension 
>> (infinite child dictionaries or lists) of data where QHash can't 
>> (it's C++ template) so I'm wondering is there any Qt class can deal 
>> with dynamic dimension of dictionary?
>>
>>
>
> Well, you can, actually. If you use QVariantHash (a typedef for 
> QHash<QVariant>), you can store basically anything in your hash, 
> including another QVariantHash. That would allow you the recursion 
> you're after, at the price of dealing with QVariants. Of course you 
> can also use other types than QVariantHash of course, if you register 
> them for usage with QVariant.
I can't expand QVariantHash by width at runtime because it's a C++ 
templatewhere in python I can expand the dictionary in two dimensions 
during insert process without any problem (just like making a tree).

-- 
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100525/7b8dec00/attachment.html 


More information about the Qt-interest-old mailing list