Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / How can i save more then 1 rich edit

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. 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
Message2. Re: How can i save more then 1 rich edit
#519
Posted by: guidance 2002-09-30 10:05:23
You mean save many richedits in one file? or specify many richedits in one savedialog and then save them individually?
Message3. 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
Message4. You must design a data structure
#524
Posted by: guidance 2002-10-01 08:08:50
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.
Message5. 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.
Message6. QFileStream
#529
Posted by: guidance 2002-10-02 07:25:06
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.
Message7. 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?
Message8. Re: QFileStream
#531
Posted by: guidance 2002-10-02 10:50:54
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 First 1 Last
掌柜推荐
 
 
¥860.00 ·
 
 
¥900.00 ·
 
 
¥810.00 ·
 
 
¥317.00 ·
 
 
¥1,370.00 ·
 
 
¥660.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0