Results 1 to 14 of 14

Thread: QDomDocument::attribute() failes to read Russian characters

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2007
    Posts
    7
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QDomDocument::attribute() failes to read Russian characters

    I wrote a tiny app that has a dialog and two labels. The first label should show the Russian characters as text of a node and the second label should show the characters as value of an attribute. Result: Both texts are not correct.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QDomDocument::attribute() failes to read Russian characters

    Could you attach the questionable xml file here? I'd like to take a look at it.

  3. #3
    Join Date
    Oct 2007
    Posts
    7
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QDomDocument::attribute() failes to read Russian characters

    It seems I paid attention on the XML structure too much. If I read the file and assign the pure content to the label (no xml parsing) then the characters are not correctly shown as well.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QDomDocument::attribute() failes to read Russian characters

    Could you attach the file here?

  5. #5
    Join Date
    Oct 2007
    Posts
    7
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QDomDocument::attribute() failes to read Russian characters

    Surprisingly I had to change the extension to "txt" to make the upload work.
    Attached Files Attached Files

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QDomDocument::attribute() failes to read Russian characters

    This seems to work fine for me:
    Qt Code:
    1. #include <QtGui>
    2. #include <QtCore>
    3. #include <QtXml>
    4. #include <QtDebug>
    5.  
    6. int main(int argc, char **argv){
    7. QApplication app(argc, argv);
    8. QFile f("Test.txt");
    9. f.open(QFile::ReadOnly);
    10. qDebug() << doc.setContent(f.readAll());
    11. QDomElement elem = doc.documentElement();
    12. QDomElement txt = elem.firstChildElement("Test1");
    13. te.setPlainText(txt.text());
    14. QDomElement txt2 = elem.firstChildElement("Test2");
    15. te.append(txt2.attribute("wert"));
    16. te.show();
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 
    In both cases I receive "Срочное выключение установки задействовано". It might be because for my system local Qt encoding is utf-8. In your case I think you should add a header to the xml file specifying the utf-8 encoding.

  7. #7
    Join Date
    Oct 2007
    Posts
    7
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QDomDocument::attribute() failes to read Russian characters

    According to your include statements you seem to use Qt 4. I had to modify your code to make it compile with my Qt 3 but now it works. Now I have to find out what I did wrong???

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QDomDocument::attribute() failes to read Russian characters

    Could you show us your non-working code?

Similar Threads

  1. Problem at time compilation in traslation of language
    By thomasjoy in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2007, 14:18

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
  •  
Qt is a trademark of The Qt Company.