Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
This post has been edited 1 times, last edit by "tavi" (May 6th 2008, 11:46am)
well everything is possible)). If conditions are met there is QGroupBox, QRadioButton and QRadioButton - write their values to a db.|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
void spare_channel::on_pushButton_clicked()
{
QList<QRadioButton*> rbtns = this->findChildren<QRadioButton*>();
int i,j;
for (i = 0; i < rbtns.count(); ++i)
{
// lookup group box
QGroupBox *gb = qobject_cast<QGroupBox*>(rbtns.at(i)->parent());
if (gb && rbtns.at(i)->isChecked())
{
for(j=0;j<rbtns.count();++j)
{
QGroupBox *gb=qobject_cast<QGroupBox*>(rbtns.at(i)->parent());
if(gb&&rbtns.at(i)->isChecked())
{
QString qu("INSERT or REPLACE INTO Spar VALUES('%1', '%2','%3')");
qu = qu.arg(gb->title())
.arg(rbtns.at(i)->text())
.arg(rbtns.at(j)->text());
QSqlQuery q;
if (!q.exec(qu))
{
QMessageBox::information(this, "Failed SQL query", q.lastError().text() + "\n" + q.lastQuery());
}
}
}
}
}
}
|
This post has been edited 2 times, last edit by "tavi" (May 15th 2008, 2:34pm)
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
if (m_RadioButton1.isChecked()) // of course instead of m_RadioButton1 there must be meaningful name of the radio button.
{
if (m_RadioButton2.isChecked())
{
if (m_RadioButton3.isChecked())
{
...save to a database some values...
}
if (m_rbPressure10Atm.isChecked())
{
...save to db...
}
....
}
.....
}
...
|
Thanks,
Quoted
Pls check the previous attachment.
This post has been edited 2 times, last edit by "tavi" (May 31st 2008, 1:03pm)