Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protocol C is unknown error in qml

Tags:

c++

qt

qml

I have a qml file , here is the source code:

import QtQuick 2.0

Image
{
    id: imageIcon;

    width: 100;
    height: 100;

    source: 'C:/Users/Public/Pictures/Sample Pictures/Chrysanthemum.jpg';
}

When I display it on a QQuickView i get this error:

QML Image: Protocol "c" is unknown

I am running the code on Windows 7 if it is relevant.

What is the correct format of the url?

like image 712
otto Avatar asked Jul 12 '13 08:07

otto


Video Answer


1 Answers

Looks like source must use a correctly formatted URL : it's either expecting a file:// scheme or a qrc:// (for stuff inside Qt resources)

Parsing of your files tries to use a "C" protocol (from C:/) which is unknown : try

source: 'file:///C:/Users/Public/Pictures/Sample Pictures/Chrysanthemum.jpg';

See : http://harmattan-dev.nokia.com/docs/platform-api-reference/xml/daily-docs/libqt4/qml-url.html

Usually you want to have your images relative (deployed near your app) or embedded into resources, not references absolutely as this will break deployment.

like image 92
Bruce Avatar answered Oct 05 '22 10:10

Bruce