【发布时间】:2023-03-14 09:36:01
【问题描述】:
我在我的 qt 快速应用程序中用相机捕获了一个图像。我想将路径发送到我的 c++ 代码并在 c++ QImage 中加载该图像。但是路径是 image://camera/preview_1,我不知道如何工作走那条路?
Camera {
id: camera
imageCapture {
onImageCaptured: {
console.log("Preview = "+preview);
photoPreview.source = preview
console.log("CapturedImagePath => "+camera.imageCapture.capturedImagePath);
up.loadImage(preview);
}
}
c++ 类
void UserProfile::loadImage(QString path)
{
QUrl imageUrl(path);
qWarning()<<"imageUrl.host()=>"<<imageUrl.host();
qWarning()<<"imageUrl.path()=>"<<imageUrl.path();
qWarning()<<"imageUrl.toLocalFile()=>"<<imageUrl.toLocalFile();
bool isOpend= m_image.load(path); //m_image is an QImage object
qWarning()<<"Image loaded=> "<<isOpend;
}
应用程序输出
D MyApp: qml: Preview = image://camera/preview_1
D MyApp: qml: CapturedImagePath =>
W MyApp: imageUrl.host()=> "camera"
W MyApp: imageUrl.path()=> "/preview_1"
W MyApp: imageUrl.toLocalFile()=> ""
W MyApp: Image loaded=> false
【问题讨论】:
-
我怀疑你真的想要captureToLocation 和imageSaved 事件
-
@selbie I seaid in my another question.the imageSaved 事件不起作用
-
回答您问题的人知道您之前问过的内容并不常见。您提出的每个问题都需要包含所有相关信息。基本上,我们需要minimal reproducible example