How to add progress bar and bookmark in qml
-
I use TextEdit to show many texts ,just a book,now i want to make a bookmark and a progress bar to show current reading ,but I have any idea about this ,can you give me some suggestion,here is my code to show the text using TextEdit in QML
@
Flickable {
id: flickablecontentHeight: edit.paintedHeight clip: true anchors.left: parent.left;anchors.leftMargin: 120 anchors.right: parent.right;anchors.rightMargin: 120 anchors.top: parent.top;anchors.topMargin: 60 anchors.bottom: parent.bottom;anchors.bottomMargin: 60 TextEdit { id: edit width: parent.width;height: parent.height activeFocusOnPress: false selectByMouse: false wrapMode: TextEdit.WrapAnywhere text:contentepub font.pixelSize: fixedFontSize textFormat: TextEdit.RichText } }
@
Thank you very much
Best regards! -
There is a ProgressBar element in QML if you using Qt Components. And what's the propose using progressBar ? Show how many pages you've reading, or just use a scrollBar if you want to show your reading progress on a page ?
And for bookmark, i think there need some tricks to save your page number, or something else into your config file(something like that). Can you describe more detailed?
-
[quote author="Chuck Gao" date="1310961687"]There is a ProgressBar element in QML if you using Qt Components. And what's the propose using progressBar ? Show how many pages you've reading, or just use a scrollBar if you want to show your reading progress on a page ? And for bookmark, i think there need some tricks to save your page number, or something else into your config file(something like that). Can you describe more detailed?[/quote]
Thank you for reply ,I want to read a book about 300 pages ,the progressBar can show the progress from page 1st to page 300st,when i scroll the text using Flickable,I want the progressBar to show correct reading progress , if i click position on the progressBar ,the Flickable can go to the fixed page by position on the progressBar .Here is my method , I count the numbers of '\n' in the text to get the page numbers,but it is not precise,i don't konw how to implement the function that when i want to go to page 45st for example ,the Flickable can go to that page.
Thank you,my friend. -
Hello, the first thing i want to highlight is the way you store your data(pages), i don't think to count "\n" is the best way to do this. How about store them in a xml file or database ?
After you determin the data storage method, you can start your implementation. To show the progress of reading is not a big deal. The key point is how you want to flip pages. You can add your pages to a listModel and show them in a listView, or you can load each of them in runtime. So, do you want your pages continuous?
-
[quote author="Chuck Gao" date="1310966952"]Hello, the first thing i want to highlight is the way you store your data(pages), i don't think to count "\n" is the best way to do this. How about store them in a xml file or database ? After you determin the data storage method, you can start your implementation. To show the progress of reading is not a big deal. The key point is how you want to flip pages. You can add your pages to a listModel and show them in a listView, or you can load each of them in runtime. So, do you want your pages continuous?[/quote]
The pages are stored in many htmls,I parse the content of html ,and set the content as text,how can a listview show a html page,i don't have any idea about this , how can i load each of them in runtime ,i want to show these htmls continuously, can you give me some suggestion ,what you have said makes me some clear.Thanks a lot!
-
There's a trivial QML progress bar in the wiki "here":http://developer.qt.nokia.com/wiki/Simple_QML_Progress_Bar.
-
Hi zhouquan, i don't think QML can display html file directly. But the Text element can be display as css styled text. When you use a listView, the most important part for your page is how you design your delegate.
As you use a html file to store the data, you can use a webpage(QML webview element) as your delegate, but it's need webkit, so you can not ignore the cost of webkit. And also, if you html file is simple(simple to read, simple to parse), you can try parse it yourself, and determin how to layout your delegate.
ListView can make your pages continuously :-)
Btw, if you still confused, you can post a topic using Chinese in Chinese forum: