Blackberry 10 SystemPrompt-> inputField不会更改用户输入的值

时间:2013-09-20 14:11:24

标签: qt blackberry-10 blackberry-cascades

我需要显示系统输入对话框:标题,一些文字,输入字段,OK&取消按钮。

我是BB开发的新手,所以我仔细阅读了文档和示例:http://developer.blackberry.com/native/documentation/cascades/ui/dialogs_toasts/prompts.html 并编写相同的代码(假设doc作者在最重要的部分中作了一些欺骗 - 不包括使用非编译源代码获取用户输入 - “qDebug()<<”Prompt Accepted:“<< text ;“)

void MainPage::showPrompt() {
    SystemPrompt *dialog = new SystemPrompt();
    dialog->inputField()->setDefaultText("TEST");
    QObject::connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), 
            this, SLOT(promptHandler(bb::system::SystemUiResult::Type)));
    dialog->show();
}


void MainPage::promptHandler(bb::system::SystemUiResult::Type value) {
    if (value == SystemUiResult::ConfirmButtonSelection) {
        SystemPrompt *dialog = (SystemPrompt *)QObject::sender();
        qDebug("text is: '%s'", qPrintable(dialog->inputField()->defaultText()));
    }
}

无论设备/模拟器上的用户输入如何,inputField() - > defaultText()值在初始化时始终为“TEST”。

如何在此处获取用户输入? dialog-> exec()不会改变任何东西。

PS。专家级问题:如何在SystemPrompt对话框中允许空输入(默认情况下,“OK”按钮在空输入时变为禁用状态。)

1 个答案:

答案 0 :(得分:0)

羞辱我。我没有仔细阅读文档。

- > inputFieldTextEntry()确实包含用户输入。

PS。我第一次看到处理文本编辑中用户输入等简单事情的复杂逻辑......