简体   繁体   English

BlackBerry 10-对话框

[英]BlackBerry 10 - Dialog Box

I m developing one app for contact reading . 我正在开发一个用于联系人阅读的应用程序。 In contact adding page I have created some textfields like first name n last name , phone number etc. And I have created one ActionItem to save or create contact . 在联系人添加页面中,我创建了一些文本字段,例如名字,姓氏,电话号码等。并且我创建了一个ActionItem来保存或创建联系人。 like this 像这样

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

        onTriggered: {
            _contactRead.contactEditor.saveContact()

            navigationPane.pop()
        }
    }

I want to display pop up (dialog box or toast) when we click on save or create contact. 单击保存或创建联系人时,我想显示弹出窗口(对话框或吐司)。 I tried to add open() in onTriggered but confused how and where to create dialog box. 我试图在onTriggered中添加open(),但对如何以及在何处创建对话框感到困惑。

Please help me out.... 请帮帮我。

use --> alert(tr("contact saved")); 使用-> alert(tr(“联系人已保存”));

refer following sample 参考以下示例

-----------qml-------------- ----------- qml --------------

 Button {
            horizontalAlignment: HorizontalAlignment.Center

            text: qsTr("Update")

            onClicked: {
                _app.updateRecord(idUpdateTextField.text, firstNameUpdateTextField.text, lastNameUpdateTextField.text);
            }
        }

-----------------cpp file------------------- ----------------- 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 对于此处的示例应用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM