PDA

View Full Version : Signal QDataTable



cristiano
17th October 2006, 00:38
Hello all,

It would like to know as I make to "emit" a "signal" of my Thread class where it processes update events, for my Form where if it finds the QDataTable.

Necessary that the QThread method:: run () of thread returns the "QDataTable::refresh()", this must be simple more is not obtaining to make.

It will be that somebody can show an example to me, please.

Thanks,

Cris.

wysota
17th October 2006, 00:43
Could you please try to describe your problem using correct English? After reading your question a few times I still can't make anything of it. Maybe if you posted some code which would illustrate your problem, it would be easier to understand what you request. If not, please try using a dictionary or an English speaking friend.

cristiano
17th October 2006, 01:49
Sorry for the bad English wysota,

I am having difficulty in "emitting a signal" of my class Thread for form1 where I want that it makes an update "refreshs".

/**
*Class Thread.h
*/
#ifndef THREAD_H
#define THREAD_H

#include <qthread.h>

class Thread : public QThread
{
public:
Thread();

virtual void refreshSql();

virtual void run();
virtual void stop();

};

#endif
/*******************************/

/*
* Thread.cpp
*/
#include "thread.h"
Thread::Thread(){}

void Thread::run()
{
......
/* My Code ==> emit Form1->dataTable->refresh();*/
.....
}

It would like in this method Thread::run() emit a signal for my QDataTable in form1 to be brought update, and I am not to implement this.

something it type.

emit Form1->dataTable->refresh();

Cris.

wysota
17th October 2006, 06:28
I assume you are using Qt3. In that case emitting a signal from a worker thread to a widget is not thread safe. You should post an event to the widget instead - either a custom one which you will then handle yourself by implementing customEvent() and calling update() there or you can try to send a QPaintEvent event, so that it is handled by Qt internally.

Of course you'll need a pointer to the table somewhere (I guess that was your main problem). You should store it in the thread class from some point where you can access both the thread and the form in question.

I hope that helps.