Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextDocumentWriter - save To ASCII
Forum Updated to NodeBB v4.3 + New Features

QTextDocumentWriter - save To ASCII

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 718 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RichardR Offline
    RichardR Offline
    Richard
    wrote on last edited by
    #1

    Hi All,
    I have a filled QTextDocument. This prints fine to pdf. It contains text but also tables.

    I would like to save this to plain ASCII Text. This works fine but all lines are behind eachother in the file. So there is no CR/ LF inserted after each line. I AM ON WINDOWS 10 64 QT 5.3.
    I probably need a codec that adds CR/LF to the end of the lines. Any ideas? thanks!

    my code:

    QString ReportGenerator::saveReportToASCII(const QString& sFileName, std::shared_ptr<QTextDocument> report)
    {
    	QTextDocumentWriter writer(sFileName);
    	writer.setFormat("plaintext");
    	auto codec = QTextCodec::codecForName("latin1");
    	writer.setCodec(codec);
    	return writer.write(report.get()) ? sFileName: QString();
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you post a text sample to try and reproduce what you get ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved