Results 1 to 4 of 4

Thread: checkbox

  1. #1
    Join Date
    Oct 2010
    Posts
    1
    Qt products
    Qt4

    Default checkbox

    Hello All,

    I am a really newbie and try some stuf in Qt 4.7, now I would like 2 checkboxes which are just able to be checked one at a time. This is did succesfull, now I would like that one checkbox is checked then a certain value appears for example in a line edit field which I added to my ui file. And if the other checkbox is checked then another vsalue appears.

    I simple don't no how to do this.

    Thank you all,

    André

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: checkbox

    Hi,
    read about signal and slots in the documentation. That is all you need. Then simply connect the checkbox checked signal to a custom slot where you alter e.g. the text of a line edit.

  3. #3
    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: checkbox

    You would typically use radio buttons (QRadioButton) to get the mutually exclusive "checkboxes". In most GUIs check boxes (QCheckBox) operate independently of each other (although not always).

    You need to connect the QRadioButton clicked(bool) signal, or the QCheckBox stateChanged(int) signal, to a slot or slots that affect the text in the QLineEdit. Exactly what is done in the slot(s) depends on what you want in the line edit.

    D'oh! Beaten to the punch by Lykurg (again!)

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: checkbox

    Quote Originally Posted by ChrisW67 View Post
    D'oh! Beaten to the punch by Lykurg (again!)
    I am sorry (I was only faster because my answer was very fast and not so detailed as yours.)

Similar Threads

  1. CheckBox in treeview
    By ansar in forum Qt Programming
    Replies: 2
    Last Post: 16th December 2009, 05:41
  2. Need some help re-painting a checkbox
    By JimDaniel in forum Qt Programming
    Replies: 2
    Last Post: 25th January 2008, 16:08
  3. exclusive checkBox
    By mickey in forum Qt Programming
    Replies: 6
    Last Post: 4th October 2007, 18:26
  4. checkbox
    By nErnie in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2006, 21:59
  5. checkBox
    By mickey in forum Qt Programming
    Replies: 8
    Last Post: 1st April 2006, 23:05

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.