[SOLVED] Slot not receiving Signal



  • In MainWindow class.

    @this->petStage = new PetStage();

    //Initialize Preferences.
    this->preferences = new Preferences(this);

    //Initialize Interpreter.
    this->interpreter = new Interpreter(petStage, ai, &Window);

    //Initialize AI.
    this->ai = new AI(petStage, &Window);
    this->ai->moveToThread(interpreter);

    //Initialize AI connections.
    connect(this->preferences, SIGNAL(LoadPreferences()), this->ai, SLOT(LoadPreferences()));@

    Now Preferences is a QDialog, when I click "OK" it emits the signal LoadPreferences which SHOULD reach the AI class by having the MainWindow handle the connection. Unfortunately it is not being reached. If I move the Slot to the MainWindow it works. But even, then I cannot seem to have AI's Slot be reached even if I create a connection between MainWindow and AI.

    @class AI :
    public QObject
    {
    Q_OBJECT

    public:
    AI(PetStage*, Robot::Window*);
    ~AI(void);

    public slots:
    void LoadPreferences();
    void Run();
    }@



  • Hi,

    I suppose Interpreter class is a QThread inherited class.
    Is Interpreter.start() method called?
    If not, AI's slots will be never called



  • You are correct. Though Interpreter is to be called later when the button is pressed. The idea is to allow changing preferences before it starts. I guess I could get the preferences as it starts if there is no alternative.

    In short, the idea was to update without starting that thread.



  • HI,

    why you need a new Thread?
    I undestand you have some task that will be started only after some user actions.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.