luochen601
27th July 2010, 11:02
I use QListWidget for logging.
If call this method within GUI thread, it runs OK.
But if call this method from none-GUI thread, it throws error below:
QObject::connect: Cannot queue arguments of type 'QItemSelection'
(Make sure 'QItemSelection' is registered using qRegisterMetaType().)
The problem is I had never connect signal/slot with QItemSelection parameter.
I guess it happend after executing setCurrentItem() and setSelected().
So, how to call this method from none-GUI thread succussfully?
void MainWindow::updateLog(const QString& log)
{
QListWidgetItem* newItem = new QListWidgetItem;
newItem->setText(log);
ui->logList->addItem(newItem); // QListWidget
ui->logList->setCurrentItem(newItem);
ui->logList->scrollToItem(newItem);
newItem->setSelected(true);
}
If call this method within GUI thread, it runs OK.
But if call this method from none-GUI thread, it throws error below:
QObject::connect: Cannot queue arguments of type 'QItemSelection'
(Make sure 'QItemSelection' is registered using qRegisterMetaType().)
The problem is I had never connect signal/slot with QItemSelection parameter.
I guess it happend after executing setCurrentItem() and setSelected().
So, how to call this method from none-GUI thread succussfully?
void MainWindow::updateLog(const QString& log)
{
QListWidgetItem* newItem = new QListWidgetItem;
newItem->setText(log);
ui->logList->addItem(newItem); // QListWidget
ui->logList->setCurrentItem(newItem);
ui->logList->scrollToItem(newItem);
newItem->setSelected(true);
}