Results 1 to 3 of 3

Thread: Cannot open XML files processed with QDomDocument using Microsoft Word

  1. #1
    Join Date
    Dec 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Cannot open XML files processed with QDomDocument using Microsoft Word

    After processing XML files with QDomDocument and saving them like this:
    Qt Code:
    1. if(fileName!=""){
    2. QFile file(fileName);
    3. if(!file.open(QIODevice::WriteOnly)){
    4. QMessageBox::critical(this,tr("Error"),tr("Could not open file"));
    5. }else{
    6. QTextStream stream(&file);
    7. QString fdt=FDTemplate->toString();
    8. fdt.toStdString();
    9. stream<<fdt;
    10. stream.flush();
    11. file.close();
    12. }
    To copy to clipboard, switch view to plain text mode 
    the files cannot be opened using Word or FrameMaker. Frame maker error is "Invalid byte"(funky signs)" of a -byte sequence". Does anyone know
    what is going on? The files look fine when i open them with NotePad and NotePad++...

    I read somewhere that this might be casued by QString and I've tried to convert it to std::string using .toStdString() before sending to QTextStream, but that did no help.
    Last edited by Bodizo; 30th December 2011 at 13:21.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Cannot open XML files processed with QDomDocument using Microsoft Word

    Something is the output file is unexpected. We cannot see the file so we cannot tell you what.

    You should not need to use a QTextStream or convert to QString or std::string... just use QDomDocument::toByteArray() and QIODevice::write()

  3. #3
    Join Date
    Dec 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot open XML files processed with QDomDocument using Microsoft Word

    Thanks, that helped!

Similar Threads

  1. Open Microsoft excel files in QT --linux
    By qixier in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2010, 09:58
  2. Open Ms Word, Ms excel, ppt files in QT -Linux
    By amankamboj1 in forum Qt Programming
    Replies: 3
    Last Post: 5th September 2009, 08:55
  3. Getting Microsoft Word Object to SaveAs
    By jvwebb in forum Newbie
    Replies: 3
    Last Post: 2nd September 2008, 19:27
  4. invoking microsoft word from qt
    By omprakash in forum Qt Programming
    Replies: 2
    Last Post: 31st October 2007, 20:43

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.