2013-09-04 5 views
0

연락처 읽기 용 앱을 하나 개발하고 있습니다. 연락처 추가 페이지에서 이름, 성, 전화 번호 등의 텍스트 필드를 만들었습니다. 연락처를 저장하거나 만들려면 하나의 ActionItem을 만들었습니다. likeBlackBerry 10 - 대화 상자

acceptAction: ActionItem { 
     title: (_contactRead.contactEditor.mode == ContactEditor.CreateMode ? qsTr ("Create") : qsTr ("Save")) 

     onTriggered: { 
      _contactRead.contactEditor.saveContact() 

      navigationPane.pop() 
     } 
    } 

저장을 클릭하거나 연락처를 만들 때 팝업 (대화 상자 또는 토스트)을 표시하고 싶습니다. onTriggered에 open()을 추가하려했지만 대화 상자를 만드는 방법과 위치를 혼동했습니다.

저를 도와주세요 ....

+0

내 솔루션을 확인하십시오. 나는 그것이 표시 경고 알림에 도움이 될 것 같아요. – svmrajesh

답변

1

사용 -> 경고 (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