Results 1 to 7 of 7

Thread: QTextEdit

  1. #1
    Join Date
    Aug 2008
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTextEdit

    Hi,

    I have hobby.cpp, hobby.h, ui.hobby and main.cpp files.

    I've made (multiple) QTextEdit fields inside (multiple) QWidgets. Entering/editing/removing text works fine in designer. It also works fine in preview state and even when running app after compilation, but...how to save the edited QTextEdit field(s)?

    Some simple example would be appreciated

    Thanks-
    qoo

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTextEdit

    Quote Originally Posted by qoo View Post
    I have ui.hobby and ...
    qoo
    .hobby is a cool extention

  3. #3
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit

    Quote Originally Posted by qoo View Post
    how to save the edited QTextEdit field(s)?
    Save the text fields or save the contents of the text field?

    If it's contents you're looking after, check out QSettings or define your own file format and use that.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTextEdit

    QSettings should be the last option for storing a huge amount of characters (that's normally the case if you use multiple QTextEdit's). But simple take the content of your edits (returned as a QString) open a file and put the content there. For that you need QFile and probably QTextStream. Read the documentation on that. It isn't so hard.

  5. #5
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit

    Hm, indeed. In my mind it was a QLineEdit for some reason.

  6. #6
    Join Date
    Aug 2008
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Cool Re: QTextEdit

    Thanks 4 the comments. I was thinking about writing the content to file but wasn't sure if it's the right thing to do...

    ui.hobby...hmmm...what can I say thus I'm sure u know what I meant

    Finally my humblest apologies to Qt Centre gurus for unintentional and too simple minded thread title

    -thanks
    qoo

  7. #7
    Join Date
    Aug 2008
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: QTextEdit

    Quote Originally Posted by Lykurg View Post
    QSettings should be the last option for storing a huge amount of characters (that's normally the case if you use multiple QTextEdit's). But simple take the content of your edits (returned as a QString) open a file and put the content there. For that you need QFile and probably QTextStream. Read the documentation on that. It isn't so hard.
    In principal I know how it's done...but I'm a newbie on this and I get confused what files (.h, .cpp .ui and/or signals/slots) I need to edit/add to make this work. I know this is quite easy thing to do - in principal and most of u in practice 2 - but since I've never done this I don't have the needed experience to do it from the scratch. That's why I'd need a short - yet complete example how to do it - instead of bits and pieces here and there

    So if any1 knows a ready-made example - plz let me know. Me, I'm swamp in the net and haven't found a single example on this...

    -cheers
    qoo

Similar Threads

  1. QTextEdit Performance handling large paragraphs
    By netuno in forum Qt Programming
    Replies: 14
    Last Post: 1st September 2010, 22:58
  2. Drawing on QTextEdit
    By jgrauman in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2009, 09:40
  3. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  4. Re-implement mouse events of QTextEdit
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2006, 16:55
  5. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.