20200306-01 QObject::connect: Cannot queue arguments of type 'QQmlChangeSet'
外国论坛相关回答
一、问题报错
QObject:
Cannot queue arguments of type ‘QQmlChangeSet’ (Make sure ‘QQmlChangeSet’ is registered using qRegisterMetaType()
二、问题发生的前因
我在 boost 回调函数中使用了 beginInsertRows 这类更新 Tableview 的信号操作
三、问题
基本上就是因为在另外一个线程中调用 beginInsertRows 这类并非真正独立信号的函数,加之使用 boost 回调函数的方式并非是线程安全的,一个线程直接操作另外一个线程本身就是非法的,存在异常的可能性
解决方案,在回调函数中在发送一个信号,到本线程中然后再和 tableview 同一线程内更新 TableView
//伪代码
connect(this, SIGNAL(sx()), this, SLOT(rx());
void xx:onBoostSLot() {
emit sx();
}
void xx::rx() {
beginInsertRows(QModelIndex(), x, x);
endInsertRow();
}
还没有评论,来说两句吧...