首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > QT开发 >

Qt emit,该怎么处理

2013-12-11 
Qt emitQt调试的时候提示这个警告信息:QObject::connect: Cannot queue arguments of type QItemSelectio

Qt emit
Qt调试的时候提示这个警告信息:
QObject::connect: Cannot queue arguments of type 'QItemSelection'
(Make sure 'QItemSelection' is registered using qRegisterMetaType().)
QObject::connect: Cannot queue arguments of type 'QItemSelection'
(Make sure 'QItemSelection' is registered using qRegisterMetaType().)
No memory leaks detected.

我是在子线程中定义一个信号

signals:
    void UpdateCurrentItem(const int&);

在主线程中
public slots:
    void UpdateCurrentItem(const int&);

 connect(CRunProgram::Instance(),SIGNAL(UpdateCurrentItem(const int&)),this,SLOT(UpdateCurrentItem(const int&)),Qt::DirectConnection);


void CProgramListPage::UpdateCurrentItem(const int& iIndex)
{
    QModelIndex current = m_ParentIndex.child(iIndex+1,0);
    m_pList->setCurrentIndex(current);
}

我这个就是通过子线程更新qtreeview的当前选择项。
不知道为什么报哪个警告。
我把这句注释掉就没有警告产生
m_pList->setCurrentIndex(current);

但是直接在主线程中调用这句又不会产生警告。
[解决办法]
你这儿的 Qt::DirectConnection 有问题。

QWidget 及其派生类都不是线程安全的,你不能再次线程中调用。

热点排行