qvariant.sip 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // qvariant.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtCore Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QVariant /AllowNone,TypeHint="Any",TypeHintValue="None"/
  22. {
  23. %TypeHeaderCode
  24. #include <qvariant.h>
  25. %End
  26. %ConvertToTypeCode
  27. if (sipIsErr == NULL)
  28. // We can convert everything to a QVariant.
  29. return 1;
  30. // If it is already a QVariant then just return it.
  31. if (Py_TYPE(sipPy) == sipTypeAsPyTypeObject(sipType_QVariant))
  32. {
  33. *sipCppPtr = reinterpret_cast<QVariant *>(sipConvertToType(sipPy,
  34. sipType_QVariant, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr));
  35. return 0;
  36. }
  37. // Convert it to a QVariant.
  38. QVariant var = qpycore_PyObject_AsQVariant(sipPy, sipIsErr);
  39. if (*sipIsErr)
  40. return 0;
  41. *sipCppPtr = new QVariant(var);
  42. return sipGetState(sipTransferObj);
  43. %End
  44. %ConvertFromTypeCode
  45. return qpycore_PyObject_FromQVariant(*sipCpp);
  46. %End
  47. public:
  48. QVariant();
  49. QVariant(SIP_PYOBJECT obj);
  50. %MethodCode
  51. int is_err = 0;
  52. QVariant var = qpycore_PyObject_AsQVariant(a0, &is_err);
  53. if (is_err)
  54. sipCpp = 0;
  55. else
  56. sipCpp = new QVariant(var);
  57. %End
  58. ~QVariant();
  59. SIP_PYOBJECT value() const;
  60. %MethodCode
  61. sipRes = qpycore_PyObject_FromQVariant(*sipCpp);
  62. %End
  63. int userType() const;
  64. const char *typeName() const;
  65. bool canConvert(QMetaType targetType) const;
  66. bool convert(QMetaType type);
  67. bool isValid() const;
  68. bool isNull() const;
  69. void clear();
  70. void load(QDataStream &ds) /ReleaseGIL/;
  71. void save(QDataStream &ds) const /ReleaseGIL/;
  72. void swap(QVariant &other /Constrained/);
  73. QMetaType metaType() const;
  74. bool canView(QMetaType targetType) const;
  75. int typeId() const;
  76. };
  77. QDataStream &operator>>(QDataStream &s, QVariant &p /Constrained/) /ReleaseGIL/;
  78. QDataStream &operator<<(QDataStream &s, const QVariant &p /Constrained/) /ReleaseGIL/;
  79. bool operator==(const QVariant &a, const QVariant &b);
  80. bool operator!=(const QVariant &a, const QVariant &b);
  81. typedef QHash<QString, QVariant> QVariantHash /TypeHint="Dict[QString, QVariant]"/;
  82. typedef QList<QVariant> QVariantList /TypeHint="List[QVariant]"/;
  83. typedef QMap<QString, QVariant> QVariantMap /TypeHint="Dict[QString, QVariant]"/;
  84. typedef std::pair<QVariant, QVariant> QVariantPair /TypeHint="Tuple[QVariant, QVariant]"/;