As mentioned in #1198 , it would be good if we could connect directly between signals and slots of QObjects.
The new Qt API for QObject::connect has the issue that it is heavily templated, which doesn't lend itself well to a general solution in CXX.
However, the older QObject APIs that take const char* still exist: https://doc.qt.io/qt-6/qobject.html#connect-1
If we could replicate the SLOT and SIGNAL macros, it would be possible to expose this function ourselves.
Luckily, this doesn't seem hard to do, the Qt sources show that these macros just end up pre-pending "1" and "2" to the signature (and call qFlagLocation in DEBUG).
We could provide our own macros that add these prefixes, and also translate the signature from C++ to Rust, so that:
QObject::connect(scrollBar, SIGNAL(valueChanged(int)),
label, SLOT(setNum(int)));would become:
QObject::connect(scrollBar, signal!(value_changed(i32)),
label, slot!(set_num(i32)));Note that the macro should probably return NewType wrappers around &'static str so that we add a bit more type safety.
Activity
0No activity yet.