[Qt-interest] check box problem
Andre Somers
andre at familiesomers.nl
Wed May 12 13:48:55 CEST 2010
On 12-5-2010 13:35, Ramesh wrote:
>
> *Hi, all*
>
> * *
>
> *What is the mistake in this code,*
>
> *Initially, all the check boxes will be selected, later if I click
> first checkbox, it will get untick, later if I click on the first box
> again, it will get selected but the second one will be unticked..
> similarly if I reaped the process, the third box also get unticked..
> my I know where I am wrong...*
>
> * *
>
That is the expected behaviour from radio buttons. You did not specify
what kind of behaviour you are looking for, so I have no idea what you
want to achieve. Perhaps you should use QCheckBox instead? QRadioButtons
are supposed to be mutually exclusive.
André
> *Here is the code **L***
>
> * *
>
> *QtRadioButtons::QtRadioButtons*(QWidget *parent)
>
> : *QMainWindow*(parent)
>
> {
>
> //ui.setupUi(this);
>
> RadioButtonwidget *myradio = *new* RadioButtonwidget();
>
> *setCentralWidget*(myradio);
>
> }
>
> *QtRadioButtons::~QtRadioButtons*()
>
> {
>
> }
>
> *RadioButtonwidget::RadioButtonwidget*(QWidget *parent)
>
> : *QWidget*(parent)
>
> {
>
> QGroupBox *groupBox = *new* *QGroupBox*(/tr/("Exclusive Radio Buttons"));
>
> QRadioButton *radio1 = *new* *QRadioButton*(/tr/("&Radio button 1"));
>
> QObject::*connect*(radio1,*SIGNAL*(clicked(*bool*)),*this*,*SLOT*(clickkedstate(*bool*)));
>
> QRadioButton *radio2 = *new* *QRadioButton*(/tr/("R&adio button 2"));
>
> QObject::*connect*(radio2,*SIGNAL*(clicked(*bool*)),*this*,*SLOT*(clickkedstate(*bool*)));
>
> QRadioButton *radio3 = *new* *QRadioButton*(/tr/("Ra&dio button 3"));
>
> QObject::*connect*(radio3,*SIGNAL*(clicked(*bool*)),*this*,*SLOT*(clickkedstate(*bool*)));
>
> radio1->*setChecked*(*true*);
>
> radio2->*setChecked*(*true*);
>
> radio3->*setChecked*(*true*);
>
> QVBoxLayout *vbox = *new* *QVBoxLayout*;
>
> vbox->*addWidget*(radio1);
>
> vbox->*addWidget*(radio2);
>
> vbox->*addWidget*(radio3);
>
> vbox->*addStretch*(1);
>
> groupBox->*setLayout*(vbox);
>
> *setLayout*(vbox);
>
> }
>
> *RadioButtonwidget::~RadioButtonwidget*()
>
> {
>
> }
>
>
> -----------------------------------------------
>
> Robosoft Technologies - Come home to Technology
>
> Disclaimer: This email may contain confidential material. If you were
> not an intended recipient, please notify the sender and delete all
> copies. Emails to and from our network may be logged and monitored.
> This email and its attachments are scanned for virus by our scanners
> and are believed to be safe. However, no warranty is given that this
> email is free of malicious content or virus.
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100512/0ee77db1/attachment.html
More information about the Qt-interest-old
mailing list