Results 1 to 3 of 3

Thread: NotePad and WordPad (why)

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default NotePad and WordPad (why)

    I was trying to save some text from my QTextBrowser to a file like below

    Qt Code:
    1. QString strFile = QFileDialog::getSaveFileName(this);
    2. if (!strFile.isEmpty())
    3. {
    4. QFile myFile(strFile);
    5. if (myFile.open(QIODevice::WriteOnly))
    6. myFile.write(text().toUtf8());
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

    now when i look at my saved file in NotePad its one big long line but in the WordPad its okey meaning lines (newlines) are the same as what i saw in my QTextBrowser.

    Does it mean that there a special thingy for notepad?

    baray98

    P.S.
    I also tried using QTextStream to save it....

  2. #2
    Join Date
    Jul 2008
    Location
    East Coast, USA
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: NotePad and WordPad (why)

    Hi,

    Notepad can not do unix style newlines (\n) it needs dos/windows style which is (I think) '\r\n'. Wordpad on the other hand can do both

    -K

  3. #3
    Join Date
    Feb 2006
    Location
    Jarrell, Texas, USA
    Posts
    70
    Thanks
    7
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: NotePad and WordPad (why)

    If you use the QIODevice mode Text rather than WriteOnly, then the end of line character will be translated according to the local encoding, for example "\r\n" for Win32.

    Karl

  4. The following user says thank you to KaptainKarl for this useful post:

    baray98 (30th July 2008)

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.