PDA

View Full Version : Checkboxes: check and uncheck



3nc31
24th November 2007, 08:06
Hi!!!

I need emit a signal when a checkbox is uncheck. I read about stateChanged(int state), but it doesn't work :confused:

I have something like that:


QCheckBox *Login;
Login = new QCheckBox;
QLineEdit *lineLogin;
lineLogin = new LineEdit;

lineLogin -> hide();

connect(Login, SIGNAL(clicked()), this, SLOT(showLineLogin()));

void window:: showLineLogin(){ lineLogin -> show}

I want a signal that hide again the lineLogin when "Login" is unchecked

How can I do that???

Thanks!!!

bender86
24th November 2007, 10:44
connect(login,signal(toggled(bool)),this,SLOT(show Login(bool)))

...

void window::showLogin(bool checked)
{
if(checked) {
loginLine->show();
} else {
loginLine->hide();
}
}

vycke
5th June 2008, 21:26
(old post, but I have a quicker/cleaner solution)


connect(login, SIGNAL(toggled(bool)), loginLine, SLOT(setVisible(bool)));

(and in fact, it can be done in designer (if you're using it), in the signals/slots window)

Vycke