사용 -> 경고 (TR은 ("연락처 저장"));
은 ----------- QML --------------
Button {
horizontalAlignment: HorizontalAlignment.Center
text: qsTr("Update")
onClicked: {
_app.updateRecord(idUpdateTextField.text, firstNameUpdateTextField.text, lastNameUpdateTextField.text);
}
}
------ 샘플
다음 참조 ----------- CPP 파일 -------------------
bool App::updateRecord(const QString &customerID, const QString &firstName, const QString &lastName)
{
bool intConversionGood = false;
const int customerIDKey = customerID.toInt(&intConversionGood);
if (!intConversionGood) {
alert(tr("You must provide valid integer key."));
return false;
}
QSqlDatabase database = QSqlDatabase::database();
QSqlQuery query(database);
const QString sqlCommand = "UPDATE customers "
" SET firstName = :firstName, lastName = :lastName"
" WHERE customerID = :customerID";
query.prepare(sqlCommand);
query.bindValue(":firstName", firstName);
query.bindValue(":lastName", lastName);
query.bindValue(":customerID", customerIDKey);
bool updated = false;
if (query.exec()) {
if (query.numRowsAffected() > 0) {
alert(tr("Customer with id=%1 was updated.").arg(customerID));
updated = true;
} else {
alert(tr("Customer with id=%1 was not found.").arg(customerID));
}
} else {
alert(tr("SQL error: %1").arg(query.lastError().text()));
}
database.close();
return updated;
}
For sample app from here
내 솔루션을 확인하십시오. 나는 그것이 표시 경고 알림에 도움이 될 것 같아요. – svmrajesh