QGIS/python/PyQt6/core/auto_generated/qgsvariantutils.sip.in
Nyall Dawson 3dc17faca6
Add utilities to convert between QMetaType::Type and QVariant::Type
While QVariant::Type can be directly static_cast to QMetaType::Type,
the reverse is not true and many QMetaType::Type values don't
have exact counterparts in QVariant::Type.

So we use the logic:

- If no conversion is possible, QVariant::UserType will be returned.
  Note that we don't use QVariant::Invalid, as the value DOES have
  a type, it's just one which needs special handling (just like user
  types do)
- Some conversions are lossy, in that the QVariant::Type cannot
  represent the full range of values possible in QMetaType::Type.
  In these cases the returned type will be an "expanded" type
  capable of storing the full range of values possible in the
  original type. Eg we map QMetaType::Type::Float to QVariant::Type::Double

QgsVariantUtils::variantTypeToMetaType is included for clarity/
completeness/future proof-ness, even though it currently can
be handled with just a simple static cast.
2024-01-24 09:49:43 +10:00

53 lines
1.8 KiB
Plaintext

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsvariantutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsVariantUtils
{
%Docstring(signature="appended")
Contains utility functions for working with QVariants and QVariant types.
.. versionadded:: 3.24
%End
%TypeHeaderCode
#include "qgsvariantutils.h"
%End
public:
static QString typeToDisplayString( QVariant::Type type, QVariant::Type subType = QVariant::Type::Invalid );
%Docstring
Returns a user-friendly translated string representing a QVariant ``type``.
The optional ``subType`` can be used to specify the type of variant list or map values.
%End
static bool isNull( const QVariant &variant );
%Docstring
Returns ``True`` if the specified ``variant`` should be considered a NULL value.
This method is more rigorous vs QVariant.isNull(), which will return
``False`` on newer Qt versions for tests like `QVariant( QDateTime() ).isNull()`.
.. versionadded:: 3.28
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsvariantutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/