Qml - qml 中的 C++ 信号参数 "undefined"
Qml - c++ signal parameters "undefined" in qml
我从工作线程接收到信号并通过 C++ Singleton (CTaskManager) 将其重新发送到 qml。
void CTaskManager::runAsync(CTask* task)
{
Q_CHECK_PTR(task);
QThread* thread = new QThread();
task->moveToThread(thread);
connect(this , SIGNAL(canceled()) , task , SLOT(cancel()) , Qt::DirectConnection);
connect(task , SIGNAL(progressChanged(float)) , this , SLOT(setProgress(float)) , Qt::DirectConnection);
connect(task , SIGNAL(finished(bool,unsigned int, const QVariantMap&)) , this , SLOT(setFinished(bool,unsigned int, const QVariantMap&)) , Qt::DirectConnection);
connect(thread , SIGNAL(started()) , task , SLOT(run()));
connect(task , SIGNAL(finished(bool,unsigned int, const QVariantMap&)) , thread, SLOT(quit()));
connect(thread , SIGNAL(finished()) , task , SLOT(deleteLater()));
connect(thread , SIGNAL(finished()) , thread, SLOT(deleteLater()));
thread->start();
}
void CTaskManager::setFinished(bool canceled, unsigned int error, const QVariantMap& args)
{
emit this->finished(canceled, error, args);
}
这适用于 LINUX 下的 Qt Creator 4.6.1。当我 运行 在 Windows 下的同一个项目时,我在我的 qml 信号连接中只得到未定义的参数。
Connections
{
target: TaskManager
onFinished:
{
}
}
有什么想法吗?
这似乎是 Qt 5.11 中已知的错误。
我从工作线程接收到信号并通过 C++ Singleton (CTaskManager) 将其重新发送到 qml。
void CTaskManager::runAsync(CTask* task)
{
Q_CHECK_PTR(task);
QThread* thread = new QThread();
task->moveToThread(thread);
connect(this , SIGNAL(canceled()) , task , SLOT(cancel()) , Qt::DirectConnection);
connect(task , SIGNAL(progressChanged(float)) , this , SLOT(setProgress(float)) , Qt::DirectConnection);
connect(task , SIGNAL(finished(bool,unsigned int, const QVariantMap&)) , this , SLOT(setFinished(bool,unsigned int, const QVariantMap&)) , Qt::DirectConnection);
connect(thread , SIGNAL(started()) , task , SLOT(run()));
connect(task , SIGNAL(finished(bool,unsigned int, const QVariantMap&)) , thread, SLOT(quit()));
connect(thread , SIGNAL(finished()) , task , SLOT(deleteLater()));
connect(thread , SIGNAL(finished()) , thread, SLOT(deleteLater()));
thread->start();
}
void CTaskManager::setFinished(bool canceled, unsigned int error, const QVariantMap& args)
{
emit this->finished(canceled, error, args);
}
这适用于 LINUX 下的 Qt Creator 4.6.1。当我 运行 在 Windows 下的同一个项目时,我在我的 qml 信号连接中只得到未定义的参数。
Connections
{
target: TaskManager
onFinished:
{
}
}
有什么想法吗?
这似乎是 Qt 5.11 中已知的错误。