form.h
class form
:public QDialog, Ui
::form{
Q_OBJECT
public:
bool isUpdate;
public slots:
double calculate
(const QString &id
);
};
#endif
class form:public QDialog, Ui::form
{
Q_OBJECT
public:
bool isUpdate;
QString totaID;
form(QWidget *parent = 0
, const QString &uid = QString::nulll);
public slots:
double calculate(const QString &id);
};
#endif
To copy to clipboard, switch view to plain text mode
form.cpp
double form
::calculate(const QString &id
) {
totaID = id;
load();
return spin->value();
}
double form::calculate(const QString &id)
{
totaID = id;
load();
return spin->value();
}
To copy to clipboard, switch view to plain text mode
and after that I create a custom sqltablemodel
{
if (value.isValid() && role == Qt::DisplayRole) {
if (index.column() == 5){
calculate(index.sibling(index.row(),3).data().toString());
return QString("%L1").
arg((d
),
0,
'f',
2).
leftJustified(true);
}
return value.toString().leftJustified(true);
}
return value;
}
QVariant CustomSql::data(const QModelIndex &index, int role) const
{
QVariant value = QSqlTableModel::data(index, role);
if (value.isValid() && role == Qt::DisplayRole) {
if (index.column() == 5){
calculate(index.sibling(index.row(),3).data().toString());
return QString("%L1").arg((d),0,'f',2).leftJustified(true);
}
return value.toString().leftJustified(true);
}
return value;
}
To copy to clipboard, switch view to plain text mode
am I clear?
Bookmarks