Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Button clicked() and setText other form's label

Button clicked() and setText other form's label

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 2 Posters 3.2k Views
  • 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 Offline
    Z Offline
    ZekDe
    wrote on last edited by
    #1

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

    K 1 Reply Last reply
    0
    • Z ZekDe

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

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @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
      4
      • Z Offline
        Z Offline
        ZekDe
        wrote on last edited by ZekDe
        #3

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

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZekDe
          wrote on last edited by
          #4

          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
          0
          • Z ZekDe

            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 Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            @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
            1
            • Z Offline
              Z Offline
              ZekDe
              wrote on last edited by koahnig
              #6

              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
              0
              • Z ZekDe

                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 Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                @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
                0
                • Z Offline
                  Z Offline
                  ZekDe
                  wrote on last edited by
                  #8

                  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
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved