02-26-2013 09:41 AM
Hi, I have simple problem here:
I have a ListView that when selected will push NavigationPane with a long description on it.
The long description is stored in dataModel which also contain title for the list.
The problem is the \n (New Line) inside the description is literally printed as "\n" and not making a new line.
I tried typing "Hello\nWorld" inside TextArea.text and it does create new line.
So, what's the problem here? Any solution? Thanks
Solved! Go to Solution.
02-26-2013 09:48 AM
Hi, I manage to find a way to solve this by literally add new line in the dataModel.
<root> <header title="Group 1" > <item title="Item 1" description="1. Hello 2. World 3. Bye!" /> </header>
This way, the code become messy. Is there any better solution?
02-26-2013 09:51 AM - edited 02-26-2013 10:00 AM
'\n' resolves to single character with ASCII code 10.
\n in dataModel text is two characters and not the newline.
How do you create and populate the dataModel?
This code in XML should be equivalent to '\n' in C++ code but regular newlines will also stay:
Another option is loading XML manually using QXmlStreamReader, replacing newlines with spaces and "\n"-s with newlines, then adding the data to GroupDataModel or ArrayDataModel. XmlDataModel is not very flexible and doesn't allow editing of it's data.
02-26-2013 10:04 AM
Thanks does work to replace new line
For now, the data model is still hard-coded. User will be able to add more list later.
By the way, is there easy way to create ordered list / numbering? I prefer doing it in QML than C++.
02-26-2013 10:11 AM