Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Slot not receiving Signal

[SOLVED] Slot not receiving Signal

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Elegant
    wrote on last edited by
    #1

    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();
    }@

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

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

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Elegant
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          HI,

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

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved