void SchetWin::on_pushButton_2_clicked(){ int sel=listWidget->currentRow(); if (sel > -1) { SchetEdit *schetEdit = new SchetEdit(0); schetEdit->setModal(true); schetEdit->setWindowTitle(tr("Редактирование счета")); schetEdit->show(); schetEdit->comboBox->setVisible(false); schetEdit->label_2->setVisible(false); schetEdit->name = listWidget->item(sel)->text(); }}
#include "schetedit.h"// place your code hereSchetEdit::SchetEdit(QWidget *parent):QDialog(parent){ setupUi(this); shows();}void SchetEdit::shows(){ if (name > "") { QString sql ="SELECT sh_id,sh_name,defaults FROM schet WHERE sh_name='"+name+"'"; query.exec(sql); query.next(); lineEdit->setText(query.value(1).toString()); checkBox->setChecked(query.value(2).toBool()); id = query.value(0).toString(); } }
C++ (Qt)void SchetWin::on_pushButton_2_clicked(){ int sel=listWidget->currentRow(); if (sel < 0 ) return; SchetEdit *schetEdit = new SchetEdit(listWidget->item(sel)->text(), 0); schetEdit->setModal(true); schetEdit->setWindowTitle(tr("Редактирование счета")); schetEdit->show(); schetEdit->comboBox->setVisible(false); schetEdit->label_2->setVisible(false);}/*--------*/#include "schetedit.h" // place your code hereSchetEdit::SchetEdit(const QString &invoiceName, QWidget *parent):QDialog(parent){ setupUi(this); shows(invoiceName);} void SchetEdit::shows(const QString &invoiceName){ if (invoiceName.isEmpty()) return; query.prepare("SELECT sh_id,sh_name,defaults FROM schet WHERE sh_name=:name"); query.bindValue(":name", invoiceName); if (!query.first()) return; lineEdit->setText(query.value(1).toString()); checkBox->setChecked(query.value(2).toBool()); id = query.value(0).toString();}