Results 1 to 11 of 11

Thread: set the validation for checkboxes

  1. #1
    Join Date
    Aug 2012
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default set the validation for checkboxes

    I want one example to set the validation for checkboxes?

  2. #2
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: set the validation for checkboxes

    By validation if you mean to check whether the checkbox is checked or not use isChecked() method to find it out.

  3. #3
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: set the validation for checkboxes

    hi,


    Qt Code:
    1. class myClass:public ....
    2. {
    3. ........
    4. ........
    5. private:
    6. int nCnt;
    7. private slots:
    8. void chkClicked(int nState);
    9. };
    10. QCheckBox *c1 = new QCheckBox;
    11. connect(c1,SIGNAL(stateChanged(int)),this,SLOT(chkClicked(int)));
    12.  
    13. //Constructor
    14. myClass::myClass()
    15. {
    16. ....
    17. ....
    18. nCnt = 0;
    19. ....
    20. ....
    21. }
    22.  
    23. void myClass::chkClicked(int nState)
    24. {
    25. if( nState == Qt::Checked)
    26. {
    27. nCnt++;
    28. //Check box checked
    29. }
    30. else if( nState == Qt::Unchecked)
    31. {
    32. //Check box unchecked
    33. nCnt--;
    34. }
    35. }
    To copy to clipboard, switch view to plain text mode 

    Use this nCnt to find the number checkboxes clicked.

    hope it helps,
    Bala

  4. #4
    Join Date
    Aug 2012
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: set the validation for LineEdit

    I used this code in my program.but it doesn't work .

    QDoubleValidator *validator=new QDoubleValidator(18.5,39.0,1,m_ui->lineEdit);
    m_ui->lineEdit->setValidator(validator);

    I want to set the validation for LineEdit .plz reply me
    Last edited by sangee; 17th August 2012 at 13:01.

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: set the validation for LineEdit

    A QLineEdit *is not* a checkbox.

    I used this code in my program.but it doesn't work .
    Why not? What isn't working? If you don't show us any code, we could guess forever about what is wrong.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  6. #6
    Join Date
    Aug 2012
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: set the validation for LineEdit

    I used this code in my program.but it doesn't work .

    QDoubleValidator *validator=new QDoubleValidator(18.5,39.0,1,m_ui->lineEdit);
    m_ui->lineEdit->setValidator(validator);

    I want to set the validation for LineEdit .plz reply me

  7. #7
    Join Date
    Sep 2011
    Posts
    26
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: set the validation for LineEdit

    Quote Originally Posted by sangee View Post
    I used this code in my program.but it doesn't work .

    QDoubleValidator *validator=new QDoubleValidator(18.5,39.0,1,m_ui->lineEdit);
    m_ui->lineEdit->setValidator(validator);

    I want to set the validation for LineEdit .plz reply me
    and WHAT is your problem?

  8. #8
    Join Date
    Aug 2012
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: set the validation for LineEdit

    I used keyboard design in my program.I want to set the values 18.5 to 39.0 only for keyboard's LineEdit.how to set the validation for this LineEdit?

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: set the validation for LineEdit

    We don't want to know what you are trying to do; that is evident from the correct code you posted. We want to know why you think it is "not working" and how you determined that.

  10. #10
    Join Date
    Aug 2012
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: set the validation for LineEdit

    QDoubleValidator consider for decimal points only not range(18.5 to 39.0).how i set the validation for this LineEdit? I want one example for LineEdit Validation.

  11. #11
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: set the validation for LineEdit

    There is not standard way (known to me) to achieve this. You should write your own validator.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. How to set the validation for checkboxes?
    By sangee in forum Qt Programming
    Replies: 1
    Last Post: 10th August 2012, 07:59
  2. XML Validation
    By NoRulez in forum Qt Programming
    Replies: 4
    Last Post: 15th September 2010, 13:07
  3. Validation
    By Tavit in forum Qt Programming
    Replies: 2
    Last Post: 21st March 2009, 07:03
  4. validation on an IP address
    By rajveer in forum Qt Programming
    Replies: 15
    Last Post: 24th August 2008, 00:35
  5. Suggestions for validation XML with XSD
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 12th June 2008, 19:00

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.