@SGaist This is the solution! Thank you very much. Below is my new setData() and TextEdited()
setData()
bool SummaryModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (index.isValid() && role == Qt::EditRole)
{
SetSummaryQuantity(value.toInt());
emit dataChanged(index,index);
return true;
}
else
{
return false;
}
return false;
}
TextEdited()
void QueriesCreator::on_quantityGeneralInformationLineEdit_textEdited(const QString &arg1)
{
calculations.SetMaterialQuantity(ui->quantityGeneralInformationLineEdit->text().toInt());
CalculateMaterialCostInZloty();
summaryModel->setData(ui->summaryDefaultTableView->model()->index(6,0),ui->quantityGeneralInformationLineEdit->text().toInt(),Qt::EditRole);
}
and of course the data()
QVariant SummaryModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::DisplayRole)
{
//Quantity
if (index.row() == 0 && index.column() == 0) return QString("50");
if (index.row() == 2 && index.column() == 0) return QString("100");
if (index.row() == 4 && index.column() == 0) return QString("1000");
if (index.row() == 6 && index.column() == 0) return GetSummaryQuantity();
//Currency- byc w moze w przyszlosci zmienic na inne
if (index.row() == 0 && index.column() == 1) return QString("PLN");
if (index.row() == 1 && index.column() == 1) return QString("EUR");
if (index.row() == 2 && index.column() == 1) return QString("PLN");
if (index.row() == 3 && index.column() == 1) return QString("EUR");
if (index.row() == 4 && index.column() == 1) return QString("PLN");
if (index.row() == 5 && index.column() == 1) return QString("EUR");
if (index.row() == 6 && index.column() == 1) return QString("PLN");
if (index.row() == 7 && index.column() == 1) return QString("EUR");
//Price Placeholders
//Material
if (index.row() == 0 && index.column() == 2) return QString("0,00");
if (index.row() == 1 && index.column() == 2) return QString("0,00");
if (index.row() == 2 && index.column() == 2) return QString("0,00");
if (index.row() == 3 && index.column() == 2) return QString("0,00");
if (index.row() == 4 && index.column() == 2) return QString("0,00");
if (index.row() == 5 && index.column() == 2) return QString("0,00");
if (index.row() == 6 && index.column() == 2) return QString("0,00");
if (index.row() == 7 && index.column() == 2) return QString("0,00");
//Machining
if (index.row() == 0 && index.column() == 3) return QString("0,00");
if (index.row() == 1 && index.column() == 3) return QString("0,00");
if (index.row() == 2 && index.column() == 3) return QString("0,00");
if (index.row() == 3 && index.column() == 3) return QString("0,00");
if (index.row() == 4 && index.column() == 3) return QString("0,00");
if (index.row() == 5 && index.column() == 3) return QString("0,00");
if (index.row() == 6 && index.column() == 3) return QString("0,00");
if (index.row() == 7 && index.column() == 3) return QString("0,00");
//Diference
if (index.row() == 0 && index.column() == 4) return QString("0,00");
if (index.row() == 1 && index.column() == 4) return QString("0,00");
if (index.row() == 2 && index.column() == 4) return QString("0,00");
if (index.row() == 3 && index.column() == 4) return QString("0,00");
if (index.row() == 4 && index.column() == 4) return QString("0,00");
if (index.row() == 5 && index.column() == 4) return QString("0,00");
if (index.row() == 6 && index.column() == 4) return QString("0,00");
if (index.row() == 7 && index.column() == 4) return QString("0,00");
}
if(role==Qt::TextAlignmentRole)
{
return Qt::AlignCenter;
}
return QVariant();
}
Now It works as I expect. Thanks and Have a good day!