c++ - BlackBerry 10 - 对话框

标签 c++ qt blackberry-10 cascade

我正在开发一款用于接触式阅读的应用程序。在联系人添加页面中,我创建了一些文本字段,如名字 n 姓氏、电话号码等。我还创建了一个 ActionItem 来保存或创建联系人。像这样

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

        onTriggered: {
            _contactRead.contactEditor.saveContact()

            navigationPane.pop()
        }
    }

我想在我们点击保存或创建联系人时显示弹出窗口(对话框或 toast )。我尝试在 onTriggered 中添加 open(),但对创建对话框的方式和位置感到困惑。

请帮帮我....

最佳答案

使用 --> alert(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

关于c++ - BlackBerry 10 - 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18607404/

相关文章:

c++ - 我怎样才能在另一个窗口中访问我的主窗口的值? (Qt 5.0.2)

c++ - 黑莓 10 中的 Web 服务

blackberry-10 - BB10 android 运行时推送通知

java - 学习 C/C++ 的最佳资源

c++ - 将 float/double 转换为 C++ 中的 IEEE754 表示形式

c++ - Lua 保留全局值

c++ - 用于音频输出的简单c++ win控制台程序?

c++ - 将类函数连接到按钮。(QT C++)

c++ - 日志文件不可见,除非用户退出应用程序

qt - PropertyAction 不适用于 "AnchorChanges"元素