Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt QRadioButton (1) setChecked problem



  • Hi ~~ i have connected lineedit textChanged() which is also connected to QRadiobutton in the second form with a slot and value *passed successfully from form to form

    connect(ui->statuslineedit,SIGNAL(textChanged(QString)),reg,SLOT(recieveacc(QString)));
    
    void licenceagrement::on_statuslineedit_textChanged(const QString &arg1)
    {
        Q_UNUSED(arg1)
        if(ui->licenceag->isChecked()){
          ui->statuslineedit->setText("yes");
        }else{
            ui->statuslineedit->setText("no");
        }
    }
    

    when i want to control QRadioButton which is in the first form from the second QRadiobutton nothing change
    this is the

    void registeracc::recieveacc(QString recieve){
    
        if(recieve=="yes"){
           ui->licenceagrement->setChecked(true);
           qDebug()<<recieve; //qDebug result here = "yes" on every setchecked by mouse not programmatically 
    
        }if(recieve=="no"){
            ui->licenceagrement->setChecked(false);
            qDebug()<<recieve; //qDebug result here = "no" on every setchecked by mouse not programmatically 
    }
    }
    

    is there any solution or is it a bug in QT?
    The problem is Nothing change even if the value ="yes" or "no"


  • Lifetime Qt Champion

    Hi
    Could you try

    ui->licenceagrement->hide()
    and
    ui->licenceagrement->show()

    jus to be sure you are looking at the correct one.

    setChecked should work so its something else.



  • @mrjj said in Qt QRadioButton (1) setChecked problem:

    ui->licenceagrement->hide()

    void registeracc::recieveacc(QString recieve){
    
        ch = recieve;
        if(recieve=="yes"){
            ui->licenceagrement->show();
           qDebug()<<recieve;
    
        }if(recieve=="no"){
            ui->licenceagrement->hide();
            qDebug()<<recieve;
    }
    }
    

    still the same problem it doesn't hide

    alt text


  • Lifetime Qt Champion

    Hi
    Ok then something is up as hide() can't fail as such.

    and you are 100% sure it goes into the IFs so it will call the code?



  • @mrjj said in Qt QRadioButton (1) setChecked problem:

    Hi
    Ok then something is up as hide() can't fail as such.

    and you are 100% sure it goes into the IFs so it will call the code?

    this is the the application output qDebug it's already in recieve slot
    so recieve slot get the value successfully
    every click from me (second window) it shows "yes" , then "no" .... from qDebug() in the first window
    alt text


  • Lifetime Qt Champion

    Hi

    I cant guess it. hide() cannot fail so im lost.

    How do you send signal back to the first window when no button is pressed (in dialog)?



  • @mrjj said in Qt QRadioButton (1) setChecked problem:

    Hi

    I cant guess it. hide() cannot fail so im lost.

    How do you send signal back to the first window when no button is pressed (in dialog)?

    void licenceagrement::on_licenceag_clicked()
    {
        if(ui->licenceag->isChecked()){
          ui->statuslineedit->setText("yes");
        }else{
            ui->statuslineedit->setText("no");
        }
    }
    

    this is the code of the QRadioButton in Dialog window when i click QRadiobutton in Dialog it send QString to lineedit which is also send a signal to recieve slot in registeracc Widget qDebug() show's that the public slot received the QString successfully but the If's can't do the rest and apply that to the QRadioButton in the first window (registeracc)

    alt text


  • Lifetime Qt Champion

    Hi
    Ok so it's via the text change signal back to form 1

    Could you try to place a button on form 1 and in its clicked
    try
    ui->licenceagrement->hide();

    just to see it can work. All look good so im a bit baffled.



  • @mrjj said in Qt QRadioButton (1) setChecked problem:

    Hi
    Ok so it's via the text change signal back to form 1

    Could you try to place a button on form 1 and in its clicked
    try
    ui->licenceagrement->hide();

    just to see it can work. All look good so im a bit baffled.

    void registeracc::on_justtestbutton_clicked()
    {
        ui->licenceagrement->hide();
    }
    

    alt text

    from the first form it works and it hides the QRadiobutton as the picture


  • Lifetime Qt Champion

    Hi
    Ok so names etc are fine.

    Then last test

    void registeracc::recieveacc(QString recieve){
        ch = recieve;
        if(recieve=="yes"){
            ui->licenceagrement->show();
           qDebug()<<"i just called show";
        }
        if(recieve=="no"){
            ui->licenceagrement->hide();
             qDebug()<<"i just called hide";
        }
    }
    

    and tell me if the new texts show as it should ?



  • @mrjj said in Qt QRadioButton (1) setChecked problem:

    Hi
    Ok so names etc are fine.

    Then last test

    void registeracc::recieveacc(QString recieve){
        ch = recieve;
        if(recieve=="yes"){
            ui->licenceagrement->show();
           qDebug()<<"i just called show";
        }
        if(recieve=="no"){
            ui->licenceagrement->hide();
             qDebug()<<"i just called hide";
        }
    }
    

    and tell me if the new texts show as it should ?

    alt text


  • Lifetime Qt Champion

    Hi,

    In the upper part of that picture you have a lic variable that is a licenseagrement object. I suspect that this is the one you are seeing. You are likely not hiding what you think you are hiding.



  • @SGaist said in Qt QRadioButton (1) setChecked problem:

    Hi,

    In the upper part of that picture you have a lic variable that is a licenseagrement object. I suspect that this is the one you are seeing. You are likely not hiding what you think you are hiding.

    i think you are correct bro ! i used this object when i click the QRadiobutton in the first form it shows the second dialog!?



  • @Proton-Phoenix said in Qt QRadioButton (1) setChecked problem:

    @SGaist said in Qt QRadioButton (1) setChecked problem:

    Hi,

    In the upper part of that picture you have a lic variable that is a licenseagrement object. I suspect that this is the one you are seeing. You are likely not hiding what you think you are hiding.

    i think you are correct bro ! i used this object when i click the QRadiobutton in the first form it shows the second dialog!?

    i have change it now to this but the same problem
    alt text


  • Lifetime Qt Champion

    @Proton-Phoenix

    Hi
    So testWindow is the "Dialog " (in title) we see ?

    if yes, dont it miss a connect there so its textChanged signal can come back to registeracc ?

    Its a new object so its not connected.



  • @mrjj said in Qt QRadioButton (1) setChecked problem:

    @Proton-Phoenix

    Hi
    So testWindow is the "Dialog " (in title) we see ?

    if yes, dont it miss a connect there so its textChanged signal can come back to registeracc ?

    Its a new object so its not connected.

    Yes bro

    every time i click the first QRadioButton it shows The Dialog window
    then in Dialog cpp i connected it using this (i am just a beginner)

    connect(ui->statuslineedit,SIGNAL(textChanged(QString)),reg,SLOT(recieveacc(QString)));
    so the problem is the new object which is not connected??
    but how it send the QString! every time i click The QRadioButton in the dialog which was opened from the new object?
    is there any solution?
    sorry for making you all that tired but anyway it's experience for you may someday you will help another beginner on it
    Really Thank you all what you are doing guys <3

    registeracc *reg=new registeracc(); // i think the problem here it's also a new object!
      connect(ui->statuslineedit,SIGNAL(textChanged(QString)),reg,SLOT(recieveacc(QString)));
    

  • Lifetime Qt Champion

    @Proton-Phoenix
    Hi
    yes that is the issue.
    Its not the one we are looking at :)



  • @mrjj said in Qt QRadioButton (1) setChecked problem:

    @Proton-Phoenix
    Hi
    yes that is the issue.
    Its not the one we are looking at :)

    :D Strange :D ^^ Really Thank you bro all of you guys You are making Great job here <3 i wish all the best happy great life for all of you <3
    may someday someone will have the same problem and it will be in the hippocampus sql ^^ :D
    so it's changing but it doesn't show changes because it's a new object not the original form
    ^^ is there any solution !? advice !
    registeracc *reg=new registeracc();
    it accept only new object pointers to connect

    connect(ui->statuslineedit,SIGNAL(textChanged(QString)),reg,SLOT(recieveacc(QString)));



  • problem fixed ... Really Thank you guys <3
    mrjj and SGaist ...
    this is the warning which were deceiving me from the very beginning
    i thought it was a problem
    but it's the solution

    alt text


Log in to reply