views:

66

answers:

2

i got this thread.h file;

#ifndef THREAD_H
#define THREAD_H

#include <QtGui>
#include <QString>

#include <tray.h>
class svThread : public QThread {

    public:
        bool getIsPaused();
        void checkSettings();
        virtual void run();
        void setPause(bool);
signals:
        void mySignal(bool);
};

#endif // THREAD_H

and i got an tray application, named tray :P where i make a thread;

svThread a;

and im starting it.

in tray.h i also got a slot

class Tray : public QWidget
{
    Q_OBJECT

public:
    Tray();
    QMenu *trayIconMenu;

    public slots:
        void settings();
        void pause();
        void setPause(bool);

public:
    void createActions();
    void createTrayIcon();

    QAction *settingAction;
    QAction *quitAction;
    QAction *pauseAction;
    QSystemTrayIcon *trayIcon;
};

#endif

but how can i make that when i use setPause(); in the thread.cpp file that he calls setPause(); in the tray.cpp file?

thnx!!! enter code here

A: 

You just need to connect each pair of object's signals and slots just as you would normally. Take a look at Qt's documentation on the subject which is very good. Basically it is:

connect(threadObj, SIGNAL(mySignal(bool)), trayObj, SLOT(setPause(bool)));
Gianni
A: 

Try Queued Connections. Just supply fifth argument of connect Qt::QueuedConnection