May 10, 2011

situ117 situ117
Lab Rat
42 posts

[Solved] Stripping double quotes from string

 

Hi,

If I try to call toString() method on any object in QML, it’s string representation is always enclosed in escaped double quotes. For e.g.

calling toString() on a url object gave me:

\“http://en.wikipedia.org/wiki/India_(disambiguation)\”

Why is it like this ? Does QML have any function to strip these surrounding escaped double quotes ? Actually I was doing some string processing using Javascript and having these double quotes is strange.

2 replies

May 11, 2011

mbrasser mbrasser
Ant Farmer
452 posts

Could you paste an example showing the problem?

The following seems to output the correct string and length for me (doesn’t include the escaped double quotes)

  1. import QtQuick 1.0
  2.  
  3. Rectangle {
  4.     width: 400; height: 400
  5.  
  6.     property url myProp: "index.qml"
  7.  
  8.     Component.onCompleted: console.log(myProp + " " + myProp.toString().length)
  9. }

Does it work correctly for you?

Regards,
Michael

May 11, 2011

situ117 situ117
Lab Rat
42 posts

Hi,

Ok, it’s not a problem with QML. I was trying to catch linkClicked(QUrl) signal from QWebView in C++, and pass them to QML. By default QUrl encloses urls in double quotes while converting them to strings ( when I call toString() ).

Thanks for your reply !!!

 
  ‹‹ QML Performance on Colibri Board and Windows CE (~600MHz,No GPU)      Platform specific part of QML-file? ››

You must log in to post a reply. Not a member yet? Register here!