Results 1 to 3 of 3

Thread: Checkboxes: check and uncheck

  1. #1
    Join Date
    Oct 2007
    Location
    Caracas - Venezuela
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Checkboxes: check and uncheck

    Hi!!!

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

    I have something like that:

    Qt Code:
    1. QCheckBox *Login;
    2. Login = new QCheckBox;
    3. QLineEdit *lineLogin;
    4. lineLogin = new LineEdit;
    5.  
    6. lineLogin -> hide();
    7.  
    8. connect(Login, SIGNAL(clicked()), this, SLOT(showLineLogin()));
    9.  
    10. void window:: showLineLogin(){ lineLogin -> show}
    To copy to clipboard, switch view to plain text mode 
    I want a signal that hide again the lineLogin when "Login" is unchecked

    How can I do that???

    Thanks!!!
    Last edited by jpn; 6th June 2008 at 10:29. Reason: missing [code] tags

  2. #2
    Join Date
    Nov 2007
    Posts
    89
    Thanked 21 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Checkboxes: check and uncheck

    Qt Code:
    1. connect(login,signal(toggled(bool)),this,SLOT(showLogin(bool)))
    2.  
    3. ...
    4.  
    5. void window::showLogin(bool checked)
    6. {
    7. if(checked) {
    8. loginLine->show();
    9. } else {
    10. loginLine->hide();
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to bender86 for this useful post:

    3nc31 (24th November 2007)

  4. #3
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Checkboxes: check and uncheck

    (old post, but I have a quicker/cleaner solution)

    Qt Code:
    1. connect(login, SIGNAL(toggled(bool)), loginLine, SLOT(setVisible(bool)));
    To copy to clipboard, switch view to plain text mode 

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

    Vycke
    Last edited by jpn; 6th June 2008 at 10:29. Reason: missing [code] tags

Similar Threads

  1. Check and Uncheck on a Dir Tree?
    By vishal.chauhan in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2007, 11:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.