I use C ++ and Qt in my project, and my problem is that the QObject :: connect function does not connect the signal to the slot. I have the following classes:
class AddCommentDialog : public QDialog { Q_OBJECT public: ...some functions signals: void snippetAdded(); private slots: void on_buttonEkle_clicked(); private: Ui::AddCommentDialog *ui; QString snippet; };
Part of my main window:
class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void commentAddedSlot(); void variableAddedSlot(); ... private: AddCommentDialog *addCommentDialog; ... };
Ant last dialogue;
class AddDegiskenDialog : public QDialog { Q_OBJECT public: ... signals: void variableAdded(); private slots: void on_buttonEkle_clicked(); private: Ui::AddDegiskenDialog *ui; ... };
In the main window designer, I connect signals and slots:
addCommentDialog=new AddCommentDialog(); addDegiskenDialog=new AddDegiskenDialog(); connect(addDegiskenDialog, SIGNAL(variableAdded()), this, SLOT(variableAddedSlot())); connect(addCommentDialog, SIGNAL(snippetAdded()), this, SLOT(commentAddedSlot()));
Point - my commentAddedSlot connected to this signal successfully, but commentAddedSlot failed. There are macros Q_OBJECT, no warnings, for example, about slot x x. In addition to this, receivers (SIGNAL (snippetAdded ())) gives me 1, but receivers (SIGNAL (snippetAdded ())) gives me 0 and I used qmake -project; qmake and fully compile. What am I missing?
source share