Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Deserialization of QHash in PySide2
Forum Updated to NodeBB v4.3 + New Features

Deserialization of QHash in PySide2

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 387 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndrzejO
    wrote on last edited by
    #1

    Hello all

    I'm starting with python for Qt and have quick question. How do you represent QList/QHash - I expect that these are "natural" python structures. But in that case I'm struggling a bit with deserialization of data. I have C++ application that stores some data that could be later read in C++ as (after some trivial reading of magic, version, ...):

    QVariantHash header;
    in >> header; // 'in' is a QDataStream
    

    How would one do that in python? Direct translation (with header being empty dictionary) results in an error that __rshift__ accepts only following:

    PySide2.QtCore.QBitArray
    PySide2.QtCore.QByteArray
    PySide2.QtCore.QDate
    PySide2.QtCore.QDateTime
    PySide2.QtCore.QEasingCurve
    PySide2.QtCore.QLine
    PySide2.QtCore.QLineF
    PySide2.QtCore.QLocale
    PySide2.QtCore.QMargins
    PySide2.QtCore.QMarginsF
    PySide2.QtCore.QPoint
    PySide2.QtCore.QPointF
    PySide2.QtCore.QRect
    PySide2.QtCore.QRectF
    PySide2.QtCore.QSize
    PySide2.QtCore.QSizeF
    PySide2.QtCore.QTime
    PySide2.QtCore.QUrl
    PySide2.QtCore.QUuid
    PySide2.QtCore.QRegularExpression
    PySide2.QtCore.QRegExp
    PySide2.QtCore.QTimeZone
    PySide2.QtCore.QVersionNumber
    

    and there is no QDataStream.readHash or something like that. Do I need to take a peek at how it is done and do it myself by pieces (would prefer not to rely on the particular implementation - which could change between Qt versions).

    I'd appreciate some help with this.

    With regards
    Andrzej

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Interesting use case. I would recommend asking this question to the PySide mailing list. You'll find there PySide2 developers/maintainers. This forum is more user oriented.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved