Important: Please read the Qt Code of Conduct -

Form problem

  • Hi friends,
    I am connecting PLC with snap7 object and when I click the button in another form,I must send an information.How can I provide this with this same object.Do I have to create a new snap7 object in other form.

  • Lifetime Qt Champion

    Are both form in same application ?

  • I will do like this,emitting a signal from other forms to mainwindow it is okay but new problem is I cant catch which button clicked

    QPushButton *DKCS_btnx[]= {ui->DKCS_btn1,ui->DKCS_btn2,ui->DKCS_btn3,ui->DKCS_btn4,ui->DKCS_btn5,ui->DKCS_btn6};
    for(int i=0;i<6;i++)

    void dialogDKCS::ButtonHandler()
    QPushButton *button = (QPushButton *)sender();
    // ui->DKCS_btn1->setText(QString::number(button->text()[0].digitValue()));
    QPushButton btn = (QPushButton)senderSignalIndex();


    I need button index

  • Lifetime Qt Champion


    Sounds like a job for QSignalMapper.

  • Lifetime Qt Champion

    Why you need the index when you have the button that was click in "button " ?
    Just need to cast it like

    QPushButton *button = qobject_cast<QPushButton *>( sender() );
    if (button){
    button->text ...

    but as @SGaist says, a signal mapper might work better.

Log in to reply