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");
[B] result = connect(tableView, SIGNAL(activated(const QModelIndex&)),
fetchThread, SLOT(update(const QModelIndex&)));
if (!result) {
emit log("entered signal error");
}
[/B] fetchThread->setModel(model);
fetchThread->start();
fetchThread = new FetchThread;
model = new FeedModel;
bool result;
tableView->setModel(model);
emit log("Jest model");
[B] result = connect(tableView, SIGNAL(activated(const QModelIndex&)),
fetchThread, SLOT(update(const QModelIndex&)));
if (!result) {
emit log("entered signal error");
}
[/B] fetchThread->setModel(model);
fetchThread->start();
To copy to clipboard, switch view to plain text mode
The update slot:
{
log("Updating element: " + QString::number(index.
row()) + ":" + QString::number(index.
column()));
QString str
= index.
data(Qt
::DisplayRole).
toString();
model->setData(index, str+ "!");
}
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+ "!");
}
To copy to clipboard, switch view to plain text mode
Bookmarks