#qt
5 posts tagged #qt.
A moved-from std::function can still hold the callable
The standard leaves a moved-from std::function valid but unspecified. libc++ keeps a copy of a small callable in the source, libstdc++ empties it. A Qt HarmonyOS bug filed on 2026-10-12 shows the cost: a task queued to another thread was destroyed on the thread that sent it.
A Q_OBJECT that never names its class
RQT_OBJECT is written like Q_OBJECT: no class name, no base class template, no registration call. It finds its class by asking std::meta::current_function() for its parent from inside member functions defined in the class body. RQT_PROPERTY takes the exact Q_PROPERTY text, stringifies it and parses it with a consteval function, so a misspelled keyword stops the build with a message. A Qt-free reduction of both runs on Compiler Explorer.
C++26 cannot write a signal's body, so a signal became a data member
A Qt signal is a function whose body moc generates, and C++26 reflection cannot generate a function body. A callable data member does not connect, a source_location tag gives every signal the same type, and a closure tag has internal linkage. What held is a bodyless data member that finds its owner through a hidden first member: 8 bytes per signal and 8 per class, measured. A static signal costs 0 bytes and has one silent pitfall. A signal that writes its own one-line body costs nothing and is the one form for overloaded signals.
Qt accepts a QMetaObject that C++26 reflection built
Qt 6.10 builds its meta-objects from constexpr tables, so a table made by C++26 reflection goes in the same place. Stock Qt connects, invokes, reads properties of, casts to and binds in QML a class that moc never saw, and a differential test finds its QMetaObject identical to the one moc generates. Four things had to be worked around, and a signal's declaration had to change.
Replacing Qt's MOC with reflection
Qt's Meta-Object Compiler parses Q_OBJECT/Q_PROPERTY declarations and emits glue code. With C++26 reflection, Q_PROPERTY-equivalent becomes a library pattern — no external compiler, no generated files.