我想通过QT5中的firestore URI显示一张照片。我可以设置映像路径,但QT5对URI进行编码并将%2F转换为“/”,这导致firestore URI不正确。你知道吗
这个项目是为python3和pyqt5编写的。我已经尝试过使用QUrl对象及其函数将其转换为.url()、.toString()、.toDisplayString()。你知道吗
与
urllib.request.urlretrieve(uri, path)
我可以下载照片,但我想直接从firestore路径显示它,而不将其保存到磁盘。你知道吗
质量管理
Row {
anchors.horizontalCenter: parent.horizontalCenter
height: 128
spacing: 16
Image {
source: root.image
anchors.bottom: parent.bottom
}
}
Python
url = QtCore.QUrl(user['photo']).toDisplayString()
print("user url: ", user['photo'])
print("QUrl: ", url)
messagebox.setProperty('image', user['photo'])
结果
user url: https://firebasestorage.googleapis.com/v0/b/projectx-835b4.appspot.com/o/users%2FNTb2Wz2%2Fprofilepicture%2F1234.jpg?alt=media&token=3d3b25c4-78e1-48a9-a311
QUrl: https://firebasestorage.googleapis.com/v0/b/projectx-835b4.appspot.com/o/users%2FNTb2Wz2%2Fprofilepicture%2F1234.jpg?alt=media&token=3d3b25c4-78e1-48a9-a311
file:///home/tux/projectsx/content/ThankYouView.qml:112:21: QML Image: Error transferring https://firebasestorage.googleapis.com/v0/b/projectx-835b4.appspot.com/o/users/NTb2Wz2/profilepicture/1234.jpg?alt=media&token=3d3b25c4-78e1-48a9-a311 - server replied: Bad Request
通过将属性类型从string更改为url,问题得到了解决
相关问题 更多 >
编程相关推荐