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.


  • Qt Champions 2016

    Hi
    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++)
    connect(DKCS_btnx[i],SIGNAL(clicked(bool)),this,SLOT(ButtonHandler()));

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

    }

    I need button index


  • Lifetime Qt Champion

    Hi,

    Sounds like a job for QSignalMapper.


  • Qt Champions 2016

    Hi
    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.