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

馋奶兔 提交于 2019-12-24 07:06:12

问题


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 ?


回答1:


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



来源:https://stackoverflow.com/questions/50817795/qml-c-signal-parameters-undefined-in-qml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!