How do I deal with 64 bit integers in QML? I know that useless Javascript can't handle them normally as it uses doubles for everything, and if I try to use them in a signal, everything gets set to undefined
. Is there a way around this? Perhaps I have to use a QVariant
or something?
相关问题
- QML: Cannot read property 'xxx' of undefin
- QML: Cannot read property 'xxx' of undefin
- QTextEdit.find() doesn't work in Python
- QT Layouts, how to make widgets in horizontal layo
- QT GUI freezes even though Im running in separate
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Is there a non-java, cross platform way to launch
- How to get a settings storage path in a cross-plat
- Why doesn't valgrind detect a memory leak in m
- QTreeView remove decoration/expand button for all
- qt界面拥挤
- how do I correctly return values from pyqt to Java
If you do not need methods on your 64-bit object, use
Q_GADGET
to create a type that you can store in a QVariant:Register using:
You can pass this type to QML:
You cannot manipulate it directly in QML, but you can pass to slots:
You can include qglobal.h and use qint64/quint64, or qlonglong/qulonglong, which are typedefs for long long int and unsigned long long int respectively. These are recognised by the QML engine. However, creating your own typedefs, or using long long explicitly, seems not to work.
Create your own
Integer64
class derived fromQObject
and give it the functions you need, likewhere you use value() to get a string representation in QML and setValue() to set a value from a string representation.
An additional constructor can be used to efficiently create
Integer64
from C++Then register the type to QML