Is it safe to use the undocumented QObjectUserData
class and the QObject::setUserData
in Qt?
相关问题
- Sorting 3 numbers without branching [closed]
- QML: Cannot read property 'xxx' of undefin
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
In general you should not rely upon undocumented APIs. If you ever plan on upgrading Qt, then don't use it!
Instead you could look at using
QObject::setProperty
, this allows you to set not only compile time declared properties, but also dynamic properties which do not need to be declared before use. This allows you to attach arbitrary values to QObjects at run time, similar to user data.Undocumented classes are usually internal classes and not part of the Qt API. That means, no guarantee is given that the API won't change or the class is removed completely in the next Qt version. For example, qobject_p.h contains the following warning:
So if you use internal API, you're on your own, and might have to fix/reimplement whatever you were doing when switching to the next Qt version.