Russian Qt Forum

Qt => Пользовательский интерфейс (GUI) => Тема начата: vexar от Июль 22, 2009, 03:19



Название: QRadioButton + Insert
Отправлено: vexar от Июль 22, 2009, 03:19
Есть два QRadioButton

 
Код:
 RadioBox1 = new QRadioButton(tr("PK"));
 RadioBox2 = new QRadioButton(tr("MK"));

я их объединил в QButtonGroup

   
Код:
  te = new QButtonGroup();
    te->addButton(RadioBox1);
    te->addButton(RadioBox2);

но немогу сообразить как их передать в insert и чтобы RadioBox1 записывал значение в БД = 2, а RadioBox1 = 1

   
Код:
  QString str5 = LineEditName->text();
    QString str6 = LineEditPass->text();
    QSqlQuery queryy;
    queryy.exec( "INSERT INTO test (name, pass)"
                "VALUES ('"+str5+"', '"+str6+"')" );


Название: Re: QRadioButton + Insert
Отправлено: Rcus от Июль 22, 2009, 03:55
Assistant -> QButtonGroup
Цитировать
void QButtonGroup::setId ( QAbstractButton * button, int id )

Sets the id for the specified button. Note that id can not be -1.
Цитировать
int QButtonGroup::checkedId () const

Returns the id of the checkedButton(), or -1 if no button is checked.


Название: Re: QRadioButton + Insert
Отправлено: vexar от Июль 22, 2009, 06:15
А можно не большой пример? Что-то не как въехать не могу.