tomek
8th January 2006, 15:20
Hi!
I am trying to tie a signal to a slot in another thread, but in vain. The code compiles with no errors, but I get the message "entered signal error" and the link doesn't work. Could anyone help?
Creating the thread and assigning the signal to the slot:
fetchThread = new FetchThread;
model = new FeedModel;
bool result;
tableView->setModel(model);
emit log("Jest model");
result = connect(tableView, SIGNAL(activated(const QModelIndex&)),
fetchThread, SLOT(update(const QModelIndex&)));
if (!result) {
emit log("entered signal error");
}
fetchThread->setModel(model);
fetchThread->start();
The update slot:
void FetchThread::update(QModelIndex &index)
{
log("Updating element: " + QString::number(index.row()) + ":" + QString::number(index.column()));
QString str = index.data(Qt::DisplayRole).toString();
model->setData(index, str+ "!");
}
I am trying to tie a signal to a slot in another thread, but in vain. The code compiles with no errors, but I get the message "entered signal error" and the link doesn't work. Could anyone help?
Creating the thread and assigning the signal to the slot:
fetchThread = new FetchThread;
model = new FeedModel;
bool result;
tableView->setModel(model);
emit log("Jest model");
result = connect(tableView, SIGNAL(activated(const QModelIndex&)),
fetchThread, SLOT(update(const QModelIndex&)));
if (!result) {
emit log("entered signal error");
}
fetchThread->setModel(model);
fetchThread->start();
The update slot:
void FetchThread::update(QModelIndex &index)
{
log("Updating element: " + QString::number(index.row()) + ":" + QString::number(index.column()));
QString str = index.data(Qt::DisplayRole).toString();
model->setData(index, str+ "!");
}