我在 bb 10 级联中有一个选项卡式窗格,我的一个选项卡就像...在这个链接中
http://pastebin.com/LRzyNdHZ(将此链接粘贴到地址栏中,如果它没有打开)
正如您所观察到的,在“添加/删除符号”操作项中,我尝试在“AddOrDelete.qml”中有一个下拉菜单。您可以在此链接中找到“AddOrDelete.qml”
现在我在“DatabaseOperations.cpp”中有一个方法,比如......
QList<QString> DatabaseOperations::readRecords(QString tableName){
QList<QString> sym_ID_List;
// 1. Get the local DB connection. Note, called database()
// Will automatically open a connection to the database
QSqlDatabase database = QSqlDatabase::database(); // opens the default database.
// 2. Create a query to search for the records
QSqlQuery query(database);
const QString sqlQuery = "SELECT * FROM "+tableName;
if (query.exec(sqlQuery)) {
// Get the field indexes. We know the order of the fields, and could skip this step.
// However this will still work if the fi changeldse order in the query string.
const int customerIDField = query.record().indexOf("SymbolId");
// 3. Start navigating through the records by calling the 'next' function.
// When there are no longer any records it will return false.
int recordsRead = 0;
while (query.next()) {
// 4. Access the data (stored in the query) via the field indexes
// and add the data to the model.
if(!query.value(1).toString().contains("skipRecord")){
//alert("recordsRead"+query.value(1).toString());
sym_ID_List.insert(recordsRead,query.value(1).toString());
}
recordsRead++;
}
qDebug() << "Read " << recordsRead << " records succeeded";
if (recordsRead == 0) {
// alert(tr("The customer table is empty."));
}
} else {
// alert(tr("Read records failed: %1").arg(query.lastError().text()));
}
// 6. Optionally close the database connection if we no longer plan to use it
database.close();
return sym_ID_List;
}
现在我想将这些值推送到“AddOrDelete.qml”中定义的下拉列表中。
目前我在主屏幕中(即带有四个选项卡的选项卡式窗格...其中一个选项卡在第一个链接中给出)。我从带有 Id 的操作项导航到“AddOrDelete.qml”文件:“添加/删除符号”。我只有一个 app.cpp 文件,我有 Lode HomeScreen,像这样......
ApplicationUI::ApplicationUI(bb::cascades::Application *app) : QObject(app){
qmlRegisterType < Timer > ("CustomTimer", 1, 0, "Timer");
QmlDocument *qml = QmlDocument::create("asset:///Template.qml").parent(this);
qml->setContextProperty("_app", this);
TabbedPane *root = qml->createRootObject<TabbedPane>();
app->setScene(root);
}
为了您的信息,我从 Qml 本身进行了导航。要从 DatabaseOpartion() 推送 Vaues,我是否需要为“AddOrDelete.qml”创建一个单独的 .CPP。如果是这样,我如何链接“App.cpp”文件和“second.cpp”文件。我如何在主屏幕(选项卡式窗格)之间导航。自上周以来我一直面临这个问题,我想我在这里得到了解决方案,
谢谢!!!