Qml - c++ signal parameters “undefined” in qml

2019-07-31 19:09发布

I receive a signal from a worker thread and re-emit it via C++ Singleton (CTaskManager) to 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);
}

This works fine with Qt Creator 4.6.1 under LINUX. When i run the same Project under Windows i get only undefined parameters in my qml signal connection.

Connections
{
    target: TaskManager
    onFinished:
    {
    }
}

Any ideas ?

标签: qt qml qt5.10
1条回答
欢心
2楼-- · 2019-07-31 19:42

It seems like a bug in Qt 5.11 which is already known.

查看更多
登录 后发表回答