Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved Button clicked() and setText other form's label

    Mobile and Embedded
    2
    8
    2584
    Loading More Posts
    • 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.
    • Z
      ZekDe last edited by

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

      K 1 Reply Last reply Reply Quote 0
      • K
        koahnig @ZekDe last edited by

        @ZekDe

        The slider example is a classical case explaining this.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply Reply Quote 4
        • Z
          ZekDe last edited by ZekDe

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

          1 Reply Last reply Reply Quote 0
          • Z
            ZekDe last edited by

            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.

            K 1 Reply Last reply Reply Quote 0
            • K
              koahnig @ZekDe last edited by

              @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

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply Reply Quote 1
              • Z
                ZekDe last edited by koahnig

                Okay it is done like that,
                in form1.h

                private 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

                K 1 Reply Last reply Reply Quote 0
                • K
                  koahnig @ZekDe last edited by

                  @ZekDe

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

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply Reply Quote 0
                  • Z
                    ZekDe last edited by

                    Do you mean this
                    class Dialog : public QDialog
                    {
                    Q_OBJECT

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

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post