Blackberry 在BB 10级联中导航后,将值推入下拉列表
我在BB10级联中有一个选项卡式窗格,我的一个选项卡类似于…在这个链接中 (如果此链接未打开,请将其粘贴到地址栏中) 正如您所观察到的,在“添加/删除符号”操作项中,我尝试使用“AddOrDelete.qml”,其中有一个下拉列表。您可以在这个链接中找到“AddOrDelete.qml” 现在我在“DatabaseOperations.cpp”中有了一个方法,比如Blackberry 在BB 10级联中导航后,将值推入下拉列表,blackberry,blackberry-10,Blackberry,Blackberry 10,我在BB10级联中有一个选项卡式窗格,我的一个选项卡类似于…在这个链接中 (如果此链接未打开,请将其粘贴到地址栏中) 正如您所观察到的,在“添加/删除符号”操作项中,我尝试使用“AddOrDelete.qml”,其中有一个下拉列表。您可以在这个链接中找到“AddOrDelete.qml” 现在我在“DatabaseOperations.cpp”中有了一个方法,比如 QList DatabaseOperations::readRecords(QString tableName){ QList s
QList DatabaseOperations::readRecords(QString tableName){
QList sym_ID_列表;
//1.获取本地数据库连接。注意,称为数据库()
//将自动打开与数据库的连接
QSQLDABASE database=QSQLDABASE::database();//打开默认数据库。
//2.创建查询以搜索记录
QSqlQuery查询(数据库);
const QString sqlQuery=“SELECT*FROM”+表名;
if(query.exec(sqlQuery)){
//获取字段索引。我们知道字段的顺序,可以跳过这一步。
//但是,如果fi在查询字符串中更改了LDSE顺序,这仍然有效。
const int customerIDField=query.record().indexOf(“SymbolId”);
//3.通过调用“下一步”函数开始浏览记录。
//当不再有任何记录时,它将返回false。
int-recordsRead=0;
while(query.next()){
//4.通过字段索引访问数据(存储在查询中)
//并将数据添加到模型中。
如果(!query.value(1).toString()包含(“skipRecord”)){
//警报(“recordsRead”+query.value(1.toString());
sym_ID_List.insert(recordsRead,query.value(1.toString());
}
recordsRead++;
}
qDebug()如果我理解正确(并且我读了整个内容的4倍),那么您想要的是将readRecords()中的数据(即QList sym_ID_列表)放入AddOrDelete.qml中定义的下拉列表中?是的,该下拉列表位于另一个qml(AddOrDelete.qml)中我需要从当前选项卡式窗格Qml导航到其中,并推送这些值…是否要每秒从数据库中选择?否,当我移动到AddOrDelete.Qml屏幕上/之前时
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;
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);