私はQObject
の信号にラムダを接続しています:ラムダ接続時にQt :: ConnectionTypeをQObject :: connectに渡すには?
QObject::connect(handle, &BatchHandle::progressMax, [this](const ProcessHandle* const self, const int value) {
this->maxProgress(value);
});
上記のコードは問題なくコンパイルされます。
handle
オブジェクトが最終的に別のスレッドに移動するため、Qt::QueuedConnection
が絶対に必要です。
私は自分のコードにこれを追加しました:私はそれが正しく値の型を特定することを確認するために明示的なキャストを追加する方法
QObject::connect(handle, &BatchHandle::finished, [this](const ProcessHandle* const self) {
this->processIsRunning(false);
}, (Qt::ConnectionType)Qt::QueuedConnection);
お知らせ。結果:
1>src\TechAdminServices\database\techCore\processes\import\ImportManagerDialog.cpp(191): error C2664: 'QMetaObject::Connection QObject::connect<void(__cdecl taservices::ProcessHandle::*)(const taservices::ProcessHandle *),Qt::ConnectionType>(const taservices::ProcessHandle *,Func1,const QObject *,Func2,Qt::ConnectionType)' : cannot convert parameter 3 from 'taservices::`anonymous-namespace'::<lambda58>' to 'const QObject *'
1> with
1> [
1> Func1=void (__cdecl taservices::ProcessHandle::*)(const taservices::ProcessHandle *),
1> Func2=Qt::ConnectionType
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
ラムダ接続時のキューイング方法は?
ターゲットコンテキストの要件によって、直感的ではありませんが、明らかにそうではないため、これは二重であると確信していました。 –