void nozologia::on_pp1_triggered(){ double weght,hight; QDate date; QWidget *date_vvod = new QWidget; QDateEdit *date_s = new QDateEdit(date_vvod); QDateEdit *date_po = new QDateEdit(date_vvod); QToolButton *button =new QToolButton(date_vvod); date_vvod->setFixedSize(200,20); date_vvod->setWindowTitle(tr("Период отчета")); date_vvod->show(); weght = date_vvod->size().width(); hight = date_s->geometry().y(); date_po->setGeometry(weght-date_po->size().width()-25,hight,date_s->size().width(),date_s->size().height()); date_s->setCalendarPopup(true); date_po->setCalendarPopup(true); date_s->setDate(date.currentDate()); date_po->setDate(date.currentDate()); date_s->setDisplayFormat("yyyy-MM-dd"); date_po->setDisplayFormat("yyyy-MM-dd"); button->setText("OK"); button->setFixedSize(date_s->size().height(),date_s->size().height()); button->setGeometry(weght-button->size().width()-1,hight,date_s->size().height(),date_s->size().height()); button->show(); date_s->show(); date_po->show(); connect(button,SIGNAL(clicked()),this,SLOT(pp1(QDateEdit*,QDateEdit*))); connect(button,SIGNAL(clicked()),date_vvod,SLOT(close()));}void nozologia::pp1(QDateEdit *date_s,QDateEdit *date_po){ QWebView *list = new QWebView; QString html,str,SQL; list->setAttribute(Qt::WA_DeleteOnClose); QFile file("pp-1.txt"); QSqlQuery q; if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::warning(this,tr("Ошибка"),tr("Нет такого файла"),QMessageBox::Ok); } SQL = QString("SELECT 7n_recept.seria,\ 7n_recept.`nomer`,\ 7n_recept.`date_vip`,\ 7n_recept.`date_obr`,\ 7n_recept.`date_otp`,\ 7n_recept.kolvo,\ \ 7n_ls_price.price,\ (7n_recept.kolvo*7n_ls_price.price),\ 7n_doctor.pcod,\ 7n_people.fio,\ 7n_people.snils,\ \ 7n_AU.k_au,\ (\ select 7n_ls.name FROM `7n_ls` WHERE 7n_ls.id = 7n_ls_price.kod\ ),\ (\ select 7n_ls.kod FROM `7n_ls` WHERE 7n_ls.id = 7n_ls_price.kod\ )\ FROM `7n_recept`,`7n_ls_price`,7n_people,7n_doctor,`7n_AU`\ WHERE (7n_ls_price.id =7n_recept.id_ls_price)\ AND (7n_people.id=7n_recept.id_people)\ AND (7n_doctor.id =7n_recept.`id_doctor`)\ AND (7n_AU.`id`=7n_recept.`id_au`)\ AND (date_otp >= %1)\ AND (date_otp <= %2)") .arg(date_s->text()) .arg(date_po->text()); q.exec(SQL); ui->area->addSubWindow(list)->setFixedSize(1200,800); list->setWindowTitle(tr("Отчет РР-1")); list->show(); while (!file.atEnd()) { html.append(file.readLine().trimmed()); } while (q.next()) { html.append("<tr style='font-size:14'>"); str = QString("<td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%1</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%2</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%3</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%4</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%5</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%6</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%7</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%8</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%9</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%10</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%11</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%12</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%13</td>\ <td align = center valign = center style='border-right:1px solid #000000; border-bottom:1px solid #000000'>%14</td>\ <td align = center valign = center style='border-bottom:1px solid #000000'>%15</td></tr>") .arg(q.value(0).toString().trimmed()+"/"+q.value(1).toString().trimmed()) .arg(q.value(2).toString().trimmed()) .arg(q.value(3).toString().trimmed()) .arg(q.value(4).toString().trimmed()) .arg(q.value(9).toString().trimmed()) .arg(q.value(10).toString().trimmed()) .arg(q.value(7).toString().trimmed()) .arg(q.value(11).toString().trimmed()) .arg(q.value(8).toString().trimmed().right(5)) .arg(q.value(4).toString().trimmed()) .arg(q.value(13).toString().trimmed()) .arg(q.value(12).toString().trimmed()) .arg(q.value(5).toString().trimmed()) .arg(q.value(6).toString().trimmed()) .arg(q.value(7).toString().trimmed()); html.append(str); } html.append("</table>"); //qDebug() << html; list->setHtml(html);}
C++ (Qt) connect(button,SIGNAL(clicked()),this,SLOT(pp1(QDateEdit*,QDateEdit*)));