1

I have a program to preview images that store every image's path (all images are in my computer) in text file. first i open text file and read line by line images paths and store to a list then i source image to the list[i],(for i=0 to numbers of images). it returns to me some error like this:

QML Image: Cannot open: qrc:///D:/QtApp/Gui_qml_app/res/1.png%0D
DirectShowPlayerService::doSetUrlSource: Unresolved error code 800c000d

this is my text file:

file:/D:/QtApp/Gui_qml_app/res/1.png
file:/D:/QtApp/Gui_qml_app/res/2.png
file:/C:/Users/info/Desktop/wall_images/3.png

and this is my code:

           property int i: -1
            var request = new XMLHttpRequest()
            request.open('GET','in.txt')
            request.onreadystatechange = function(event) {
                if (request.readyState == XMLHttpRequest.DONE) {

                 list = request.responseText.split('\n');
                }
            }
            request.send()
    item.source =String(list[i+1])
i++;

can every one help me?

2
  • I think my problem is %0D that attached end of images path but i don't know haw can i Getting rid of that Jun 30, 2014 at 12:24
  • That's likely a newline character that is being included when you read each line from your text file - you need to find a way to strip it from the URL string. Jun 30, 2014 at 13:13

2 Answers 2

1

The DirectShow error tells us that you're running on Windows and most of the time, newlines are coded with \r\n on this platform.

Before assigning the item source path, remove the extra \r:

list[i+1] = list[i+1].replace(/(\r\n|\n|\r)/gm,"");
item.source = String(list[i+1])
1

thanks for your answer. I change my code in below and it's work pretty good

    property int i: -1
            var request = new XMLHttpRequest()
            request.open('GET','in.txt')
            request.onreadystatechange = function(event) {
                if (request.readyState == XMLHttpRequest.DONE) {

                 list = request.responseText.split('\n');
                }
            }
            request.send()
    item.source = String(list[i+1]).substring(0,String(list[i+1]).length-1)
i++;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .