| Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 | 1. How can i save more then 1 rich edit #518 Posted by: 2002-09-30 07:58:36 | how can i save more then one rich edit like if i have a save dialog? please help | 2. Re: How can i save more then 1 rich edit #519 | You mean save many richedits in one file? or specify many richedits in one savedialog and then save them individually? | 3. Re: How can i save more then 1 rich edit #523 Posted by: 2002-10-01 04:00:22 | to save many richedits in one file | 4. You must design a data structure #524 | 1) Use SaveToStream to get the contents of your richedit in a memory stream. 2) Save the length in the beginning of the file, also act as a pointer to the next saved richedit later. 3) Save the richedit prepared by 1) into the fiile. 4) Loop from 1) till all richedits are saved.
While reading back, check the length field accordingly.
Another way, you can preserve a block with fixed length in the beginning of the file and save all the length(pointer) fields all together (because you can use a Long as length, which themselves are all in same size). Advantage: no need to scan whole file while accessing; Disadvantage: the number of richedits you can save is limited by the size of the predefined pointer-block.
In fact, this just like designing a small file system, you know why FAT16, FAT32 ?
By the way, if you modified one richedit, you must change all the others followed in the same file and their pointers. | 5. Re: You must design a data structure #528 Posted by: 2002-10-02 05:17:02 | i didn't get one word you said...... anyway can you make me a example that would help even more. | 6. QFileStream #529 | Do you know how to save and read of QFileStream first of all?
Because your richedit is not in fixed length, so we must record the length in the file together with the contents itself, otherwise it's impossible to read it back again if there're more than one richedits saved in the same file, i.e., we must know the boundaries. In fact, there're many methods (algorithm) can do this. | 7. Re: QFileStream #530 Posted by: 2002-10-02 08:16:07 | it does have a fixed length it's 100 width and 100 height and i don't know anything about QFIle Stream... can u show me a small example? | 8. Re: QFileStream #531 | Length: I mean the bytes it occupied if saved into a file (or in memory), not appearance. Check SaveToFile/SaveToStream methods of QRichEdit: http://citymap.getmyip.com/_scripts/file.php?f=2468&r=2330
You can search "QFileStream" inside this web site, there're many examples already. Hope helpful. http://citymap.getmyip.com/_scripts/search.php | Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |
|
|