首页 > 解决方案 > 从 Qt 中的查询中读取/回调多个 firebase 值

问题描述

我正在尝试从一个命令读取我的部分数据库的所有子项,因此我可以更新 Firebase,它会自动在我的应用程序中显示为各种标题。

我要阅读的数据库部分如下:

我在 Qt 中工作,并尝试了使用 orderByKey、orderByChild 和 orderByValue 的不同组合,代码如下:

firebaseDb.getValue("public/bigqueryobject",{
                        orderByKeys: true
                    }, function(success, key, value) {
                        if(success) {
                            console.debug("Read user value for key", key, "fromFBDB: ", value);
                            myArray.push(value); combobox.model = myArray
                        }
                    })

执行上述操作时,我的日志状态:

“从 FBDB 读取 key bigqueryobject 的用户值:[object Object]

读取 keybigqueryobject 的值 [object Object]”

但是没有显示任何响应,这可能是什么问题?!?

标签: qtfirebasefirebase-realtime-databaseqt5

解决方案


因此,在之前尝试将读取值推送到数组以添加到我的组合框之后,我只获得了一个下拉选项,其中所有读取值都在一行中;只需删除数组即可完美运行,代码如下!

onFirebaseReady: {
    firebaseDb.getValue("locationsDepartments/locations", {
                            orderByValue: true
                        }, function(success, key, value) {
                             if(success) {
                                 combobox.model = value
                             } 
                       })
                  }
Quick2.ComboBox {
    id: combobox

    model: []

    delegate: Quick2.ItemDelegate {
        width: combobox.width
        height: combobox.height
        contentItem: AppText {
            text: modelData
        }
            highlighted: combobox.highlightedIndex == index
}
            contentItem: AppText {
               width: combobox.width - combobox.indicator.width - combobox2.spacing
               text: combobox.displayText
               wrapMode: Text.NoWrap
        }
}

推荐阅读