Hide/Unhide radio button and label



  • Hi,

    I have set of radio buttons (statically done using Qt Creator), they are in 4x8 metrics.
    In code I want to unhide the radio buttons in rows and set a label with there instead.

    First thing is I am not able to hide the radio buttons , I have used hide() and setVisible(FALSE).

    Please let me know how to achieve the same,

    Thanks


  • Lifetime Qt Champion

    Hi,

    Please show the code. Without it it's pretty much Crystal Ball Debugging (tm).



  • @SGaist said in Hide/Unhide radio button and label:

    ithout it it's pretty much Crystal Ball Debugging (tm).

    Below is the code, fn timeout is trying to unhide a one radio and hide another one. One thing to note is when the program gets started , it successfully unhides the last 4 radios (m45,m46,m47 and m48).

    RaptorCoreGUI::RaptorCoreGUI(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::RaptorCoreGUI)
    {
        ui->setupUi(this);
        radioButtonGrid = new QGridLayout;
    {
    
        /* Adding all the radio buttons ina grid layout */
        /* For Line Module 1 */
        radioButtonGrid->addWidget(ui->m11, 0, 0);
        radioButtonGrid->addWidget(ui->m12, 0, 1);
        radioButtonGrid->addWidget(ui->m13, 0, 2);
        radioButtonGrid->addWidget(ui->m14, 0, 3);
        radioButtonGrid->addWidget(ui->m15, 0, 4);
        radioButtonGrid->addWidget(ui->m16, 0, 5);
        radioButtonGrid->addWidget(ui->m17, 0, 6);
        radioButtonGrid->addWidget(ui->m18, 0, 7);
    
        /* For Line Module 2 */
        radioButtonGrid->addWidget(ui->m21, 1, 0);
        radioButtonGrid->addWidget(ui->m22, 1, 1);
        radioButtonGrid->addWidget(ui->m23, 1, 2);
        radioButtonGrid->addWidget(ui->m24, 1, 3);
        radioButtonGrid->addWidget(ui->m25, 1, 4);
        radioButtonGrid->addWidget(ui->m26, 1, 5);
        radioButtonGrid->addWidget(ui->m27, 1, 6);
        radioButtonGrid->addWidget(ui->m28, 1, 7);
    
        /* For Line Module 3 */
        radioButtonGrid->addWidget(ui->m31, 2, 0);
        radioButtonGrid->addWidget(ui->m32, 2, 1);
        radioButtonGrid->addWidget(ui->m33, 2, 2);
        radioButtonGrid->addWidget(ui->m34, 2, 3);
        radioButtonGrid->addWidget(ui->m35, 2, 4);
        radioButtonGrid->addWidget(ui->m36, 2, 5);
        radioButtonGrid->addWidget(ui->m37, 2, 6);
        radioButtonGrid->addWidget(ui->m38, 2, 7);
    
        /* For Line Module 4 */
        radioButtonGrid->addWidget(ui->m41, 3, 0);
        radioButtonGrid->addWidget(ui->m42, 3, 1);
        radioButtonGrid->addWidget(ui->m43, 3, 2);
        radioButtonGrid->addWidget(ui->m44, 3, 3);
        radioButtonGrid->addWidget(ui->m45, 3, 4);
        radioButtonGrid->addWidget(ui->m46, 3, 5);
        radioButtonGrid->addWidget(ui->m47, 3, 6);
        radioButtonGrid->addWidget(ui->m48, 3, 7);
        ui->m45->hide();
        ui->m46->hide();
        ui->m47->hide();
        ui->m48->hide();
    }
    void RaptorCoreGUI::timout()
    {
    ui->m45->show();
    ui->m44->hide();
    }
    
    

  • Lifetime Qt Champion

    From your code, timeout is not connected to anything.



  • @SGaist

    Sorry, It was just a code snippet, not the complete one. But I got it working with , it was my issue I did not put show() for the radio button in the actual code. In actual code I was able to hide the buttons but because I did not put show , it was not working.

    Thank you


Log in to reply
 

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