Button clicked() and setText other form's label
-
I'am trying this
BT *bt;
connect(ui->pushButton,SIGNAL(clicked(bool)),bt,SLOT(ab(bool))); this is in second forum. bt is first forum.ab(bool) is in first forum,but it didn't work.What is the error message you see?
When you use the macro driven connect you will see an error message during run time. This message tells you directly what happened.
When starting a gui you may require to start the whole application in a terminal or better is directly starting in creator. Check the "Application Output" pane.Alternatively, you can use also the functor driven connect. In your case probably:
connect(ui->pushButton, &QPushButton::clicked, bt, &BT::ab);
For some details see this
-
Okay it is done like that,
in form1.hprivate slots: void ChangeText(QString Text); private: form2 *dialog;
in form2.h
signals: void ChangeTest(QString text);
form1.cpp
void form1::Detected_Signal(QMouseEvent *ptr) { dialog->setGeometry(0,0,w,h); dialog->setModal(true); connect(dialog,SIGNAL(ChangeTest(QString)),this,SLOT(ChangeText(QString))); dialog->exec(); } void form1::ChangeText(QString Text) { if(Text == "customPlot") { ui->customPlot->clearGraphs(); timer1->stop(); } }
in form2.cpp
void Dialog::on_checkBox_stateChanged(int arg1) { emit ChangeTest("customPlot"); }
[edit: koahnig] code tags added
-
Okay it is done like that,
in form1.hprivate slots: void ChangeText(QString Text); private: form2 *dialog;
in form2.h
signals: void ChangeTest(QString text);
form1.cpp
void form1::Detected_Signal(QMouseEvent *ptr) { dialog->setGeometry(0,0,w,h); dialog->setModal(true); connect(dialog,SIGNAL(ChangeTest(QString)),this,SLOT(ChangeText(QString))); dialog->exec(); } void form1::ChangeText(QString Text) { if(Text == "customPlot") { ui->customPlot->clearGraphs(); timer1->stop(); } }
in form2.cpp
void Dialog::on_checkBox_stateChanged(int arg1) { emit ChangeTest("customPlot"); }
[edit: koahnig] code tags added