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. How to add two lineEdit in the same gridlayout on checked of radio button
Forum Updated to NodeBB v4.3 + New Features

How to add two lineEdit in the same gridlayout on checked of radio button

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 3 Posters 2.4k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    gogoi
    wrote on last edited by
    #1

    hello friends

    Actually i have two lineEdit,one gridlayout and a radio button..what i want to do is on checked of radio button i want to put my first LineEdit in the grid layout..and on unchecked of radio button i want to put my second lineEdit in gridlayout..but when i exexute my code..both my lineEdit is palced in two gridlayout..althoug there is only one gridlayout....the code i have wrriten is....

    @SettingForm::SettingForm(QWidget *parent) :QDialog(parent),ui(new Ui::SettingForm)
    {
    ui->setupUi(this);

      pEditPassEnable=new QLineEdit;
    
      pEditPassDisable=new QLineEdit;
    
    connect(ui->passwordRadiobutton,SIGNAL(toggled(bool)),this,SLOT(onCheckRadioButton(bool)));
    

    }
    @

    @bool SettingForm::onCheckRadioButton(bool checked)
    {

    if(checked)
    {
    
        pEditPassEnable->setText("Click to change Password");
    
        pEditPassEnable->setEnabled(true);
    
        pEditPassEnable->setStyleSheet("Color:rgb(255, 255, 255);");
    
        pEditPassEnable->setStyleSheet("background-color: rgb(206, 218, 214);");
    
        ui->PassgridLayout->addWidget(pEditPassEnable);
    }
    else if(!checked)
    {
    
        pEditPassDisable->setEchoMode(QLineEdit::Normal);
    
        pEditPassDisable->setText("Set Password");
    
        pEditPassDisable->setEnabled(false);
    
        pEditPassDisable->setStyleSheet("Color:rgb(128, 128, 128);");
    
        pEditPassDisable->setStyleSheet("background-color: rgb(206, 218, 214);");
    
        ui->PassgridLayout->addWidget(pEditPassDisable);
    }
    return true;
    

    }@

    can anyone please suggest me what mistake i have done in my code

    regards
    Rahul

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      your routine onCheckRadioButton is only executed on the toggled() signal.
      You need to define the visibility somewherelese, presumably your constructor.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tdmatsu
        wrote on last edited by
        #3

        I think you should do all the intializations in the constructor:

        • setting text and styles etc
        • adding to layout
        • hiding them by default (if this is what you want)

        and then just change the visibility of the labels using show()/hide() in onCheckRadioButton().

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gogoi
          wrote on last edited by
          #4

          thanks all..

          its working now..

          regards
          Rahul

          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