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]Cannot call slot=*(
Forum Updated to NodeBB v4.3 + New Features

[solved]Cannot call slot=*(

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.4k Views 3 Watching
  • 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.
  • A Offline
    A Offline
    AntonZelenin
    wrote on last edited by AntonZelenin
    #1

    LogWindow.h
    class LogWindow : public QMainWindow
    {
    Q_OBJECT
    .... //another code
    public slots:
    void replyClicked();
    signals:
    void msgSent();
    };

    LogBrain.h
    class LogBrain : public LogWindow
    {
    ....
    public slots:
    void textProcessing();
    };

    LogWindow.cpp
    void LogWindow::replyClicked()
    {
    ...
    emit msgSent();
    }

    LogBrain.cpp
    void LogBrain::textProcessing()
    {
    ....
    }

    main.cpp
    int main(int argc, char *argv[])
    {
    QApplication logApp(argc, argv);
    LogWindow *mainWnd = new LogWindow;
    LogBrain *logMind = new LogBrain;

    QObject::connect(mainWnd->ui.pushButton, SIGNAL(clicked()), mainWnd, SLOT(replyClicked()));
    QObject::connect(mainWnd, SIGNAL(msgSent()), logMind, SLOT(textProcessing()));
    
    mainWnd->show();
    return logApp.exec();
    

    }

    Can't call textProcessing() slot.
    I put a breakpoint where signal msgSent() must be emitted and until this moment everything works fine. But then this signal doesn't call slot textProcessing(). I cannot understand what's the problem. I created new project and wrote similar code and there everything is ok and textProcessing() calls without any problems.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @AntonZelenin said:
      Hi
      I am wondering if LogBrian also need a Q_OBJECT in top of class def?

      A 1 Reply Last reply
      1
      • mrjjM mrjj

        @AntonZelenin said:
        Hi
        I am wondering if LogBrian also need a Q_OBJECT in top of class def?

        A Offline
        A Offline
        AntonZelenin
        wrote on last edited by
        #3

        @mrjj

        It works!) It seemed to me, that I tried to add Q_OBJECT but there was an error, something with moc file, but now everything is good, strange. Thanks

        mrjjM 1 Reply Last reply
        0
        • A AntonZelenin

          @mrjj

          It works!) It seemed to me, that I tried to add Q_OBJECT but there was an error, something with moc file, but now everything is good, strange. Thanks

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @AntonZelenin
          Well, when I add Q_OBJECT to a class. I often go an delete whole build folder as its sometimes a bit
          hard to make it run moc fully or something like that. Sometimes a "Clean" also works.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            The thing to do when you add/remove the Q_OBJECT macro is to re-run qmake (in the Build menu of Qt Creator). That will it turn trigger moc to run again and see that your class needs to be mocked

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            A 1 Reply Last reply
            0
            • SGaistS SGaist

              Hi,

              The thing to do when you add/remove the Q_OBJECT macro is to re-run qmake (in the Build menu of Qt Creator). That will it turn trigger moc to run again and see that your class needs to be mocked

              A Offline
              A Offline
              AntonZelenin
              wrote on last edited by
              #6

              @SGaist
              Yeah, I have already realized that, but thanks)

              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