Bug on load image or video to QML using C++
Hi,
I made a project for a church that show images on projector.
On my mac(osx 10.9) and ubuntu linux 13, everything is working nice, but on Windows machine the exact software dont load the images to QML and dont load vÃ*deos to MediaPlayer.
This problems i only get on Windows.
The example project of loading video on QML works nice, but everything is done inside a QML application.
My application change the image and video dynamic invoking a method. Look the code:
FROM MY C++ APP:
Code:
QString fullFilePath
= "file://C:/PRProjector-Project/data/images/allthingsnew-background.jpg";
FROM MY QML FILE:
Code:
import QtQuick 2.2
import QtMultimedia 5.2
import QtGraphicalEffects 1.0
Item {
function loadBackgroundImage(fullFilePath)
{ backgroundImage.source = fullFilePath; }
Image
{ id: backgroundImage objectName: "backgroundImage" source: "" anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter anchors.fill: parent; }
}
ERROR:
Code:
qrc:/resources/qml/ProjectorScreen.qml:36:5: QML Image: Cannot open:
Also, I got error error event on MediaPlayer object from QML when i try load some video too.
REMEMBER: IT IS WORKING IN MAC OSX AND LINUX!
Re: Bug on load image or video to QML using C++
QUrl::fromLocalFile()
Btw, it is way more elegant to expose such a thing as a context property instead of calling into the QML scene.
Cheers,
_
Re: Bug on load image or video to QML using C++
Hi,
I have tested QUrl::fromLocalFile() before. But i will try again.
But what the correct syntax?
Code:
QString fullFilePath
= QUrl::fromLocalFile("file://C:/PRProjector-Project/data/images/allthingsnew-background.jpg").
toString() or
QString fullFilePath
= QUrl::fromLocalFile("C:/PRProjector-Project/data/images/allthingsnew-background.jpg").
toString() or
QString fullFilePath
= QUrl::fromLocalFile("C:\\PRProjector-Project\\data\\images\\allthingsnew-background.jpg").
toString()
Thanks man.
Re: Bug on load image or video to QML using C++
Also make sure you have the imageplugin for JPEG images available.
Re: Bug on load image or video to QML using C++
Hi,
The images/videos load normal when everything is set inside the QML. The problem is only on WINDOWS when i SET the path with C++.
Whats the correct way based on my last question?
Re: Bug on load image or video to QML using C++
Quote:
Originally Posted by
prchakal
But what the correct syntax?
Code:
QString fullFilePath
= QUrl::fromLocalFile("file://C:/PRProjector-Project/data/images/allthingsnew-background.jpg").
toString() or
QString fullFilePath
= QUrl::fromLocalFile("C:/PRProjector-Project/data/images/allthingsnew-background.jpg").
toString() or
QString fullFilePath
= QUrl::fromLocalFile("C:\\PRProjector-Project\\data\\images\\allthingsnew-background.jpg").
toString()
Not the first one, that is a URL as input.
My guess is that both other ones should work.
If you want to be sure use QFileDialog to get the filename and have a look at it.
Btw, I don't think there is a need for the toString() call, just send the QUrl to the QML engine.
Cheers,
_
Re: Bug on load image or video to QML using C++
Hi
I solve the problem using only:
file:C:/PRProjector-Project/data/images/allthingsnew-background.jpg
Thanks.