Important: Please read the Qt Code of Conduct -

Button clicked() and setText other form's label

  • Hi friend ,I couldnt manage to data transfer from A form to B form.Any offer ?

  • @ZekDe

    The slider example is a classical case explaining this.

  • I think this is not enough,I couldn't understand still,I need a better example,but thanks this.

  • 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.

  • @ZekDe

    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.h

    private slots:
    void ChangeText(QString Text);
    form2 *dialog;

    in form2.h

     void ChangeTest(QString text);


    void form1::Detected_Signal(QMouseEvent *ptr)
    void form1::ChangeText(QString Text)
        if(Text == "customPlot")

    in form2.cpp

    void Dialog::on_checkBox_stateChanged(int arg1)
        emit ChangeTest("customPlot");

    [edit: koahnig] code tags added

  • @ZekDe

    What is the basis of form1 and form2 classes? Are they inheriting from QObject and are you using the Q_OBJECT macro?

  • Do you mean this
    class Dialog : public QDialog

    it is in .h file.
    Sorry my late respound,I didn't get a mail for this message.

Log in to reply