Hopefully, this should be a pretty easy question. I'm working on a text-editor program, and I've reached the point of giving functionality to the various drop-down menus. Right now, I'm stuck on the save file feature. What I need is a way for the user to be prompted to save the contents of a Qrichedit box in a file of their choosing. I need them to be able to create the name of the file, as well as assign the type of file it's going to be...(*.txt, *.rtf).
The command richedit.SaveToFile("example.txt") only seems to allow the saving to a specific, predetermined file and type. And I've discovered the QSaveDialog area of the documentation, but it's description is extremely sparse. How do I use this thing to save the contents of my Qrichedit box?
2. Re: Saving files?
#5123
Posted by: 2004-09-21 10:20:43
I use a buffered method of loading and saving; an invisible RichEdit. The big advantage is that it can be used to restore (undo changes) by simply re-copying its contents when needed.
So step 1 is defining that RichEdit;
DIM RiEd as QRichEdit RiEd.plaintext = 1 RiEd.visible = 0 RiEd.Parent = Form
I only use .txt files actually. I use a string to pass the name and location of the file to be loaded to the bit of the program that does the actual loading and / or saving; this is step 2.