Results 1 to 13 of 13

Thread: problem with Hebrew font in a control

  1. #1
    Join Date
    Feb 2010
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default problem with Hebrew font in a control

    Hi.
    i am trying to made my first application in Qt.
    and i got a problem with the Hebrew.
    i made a lineEdit control with pushButton and listWidget. when the buttons clickEvent occur the text in the lineEdit goes to the listWidget,
    normally, all working perfect.
    but if im trying to insert a hardcoded item to the listwidget that writen in Hebrew i will get in the list only "????"...

    i am tried to use the:
    QTextCodec *codec = QTextCodec::codecForName("iso8859-8");but hopeless...

    any help please???

  2. #2
    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: problem with Hebrew font in a control

    Hi,

    first: How do you save your files? Suppose utf8 then try:
    Qt Code:
    1. setText(trUtf8("שלום"))
    To copy to clipboard, switch view to plain text mode 
    .
    Works for me,

    Lykurg

  3. #3
    Join Date
    Feb 2010
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: problem with Hebrew font in a control

    Thank you, but it is not working for me...
    and i am not handle with files yet...

  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: problem with Hebrew font in a control

    so how are your files are encoded? and please post the relevant code where you insert the hebrew text to the list widget.

  5. #5
    Join Date
    Feb 2010
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: problem with Hebrew font in a control

    it is only my first time i am using the Qt framework.
    and i am just tried to do a simple ui with a list and button.
    when the user press the button something will add to the list.
    in English its absolutely working but in Hebrew its doesn't.

    i tried verity of code the last one was:
    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. ui->listWidget->addItem(trUtf8("שלום"));}
    To copy to clipboard, switch view to plain text mode 

    edit:
    i even tried this code:
    Qt Code:
    1. QString text = "שלום";
    2. QTextCodec *codec = QTextCodec::codecForName("Windows-1255");
    3. QByteArray encodedString = codec->fromUnicode(text);
    4. ui->textEdit->append(encodedString);
    To copy to clipboard, switch view to plain text mode 

    Thank you for helping me!
    Last edited by HeX0R; 10th February 2010 at 11:43.

  6. #6
    Join Date
    Feb 2010
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: problem with Hebrew font in a control

    Lykurg, thank you, i did it...

    thanks the code:
    Qt Code:
    1. QByteArray encode = "שלום";
    2. QTextCodec* code = QTextCodec::codecForName("Windows-1255");
    3. QString string = code->toUnicode(encode);
    4. ui->textEdit->append(string);
    To copy to clipboard, switch view to plain text mode 
    but it is the right way to do this???

    Edit:
    something goes wrong...
    when i done this on my native system its work perfectly...
    but when i tried this code my virtual machine i got ???? again....

    Edit II:
    I have to mention that my goal is to build application for the S60 platform
    and in the VM i have the S60 SDK installed... if its change something...
    Last edited by HeX0R; 10th February 2010 at 12:33.

  7. #7
    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: problem with Hebrew font in a control

    Quote Originally Posted by HeX0R View Post
    Qt Code:
    1. QByteArray encode = "שלום";
    2. QTextCodec* code = QTextCodec::codecForName("Windows-1255");
    3. QString string = code->toUnicode(encode);
    4. ui->textEdit->append(string);
    To copy to clipboard, switch view to plain text mode 
    but it is the right way to do this???
    If it works it is ok, but it is to much for such a simple thing. Still I can only recomend to use pure utf8 for all. Files and then trUtf8.

    Edit:
    something goes wrong...
    when i done this on my native system its work perfectly...
    but when i tried this code my virtual machine i got ???? again....

    Edit II:
    I have to mention that my goal is to build application for the S60 platform
    and in the VM i have the S60 SDK installed... if its change something...
    Ahh, the s60! I had trouble with that also. I was trying to set hebrew with vovels. But with the new release I don't have had troubles. So I would suggest. make a simple compilable program which reproduce your error, and I will check it at home with my Xpressmusic and we will see further...

  8. #8
    Join Date
    Feb 2010
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: problem with Hebrew font in a control

    Thank you man...
    but i deleted the project and the entire environment and started from scrach...

    Now i can read Hebrew that hardcoded and even readen from file...

    But i have another problem with this ... ye rigth...
    I change the button "Add" to Hebrew and now he gibrish....
    you can see in the picture the button in the rigth upper corner...

  9. #9
    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: problem with Hebrew font in a control

    Quote Originally Posted by HeX0R View Post
    Now i can read Hebrew that hardcoded and even readen from file...
    יופי! With the button: Did you use designer for creating the GUI? If so, see if it uses utf8 as well. If you don't find the error just upload a running sample code and we'll see.

    Lykurg

  10. #10
    Join Date
    Feb 2010
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: problem with Hebrew font in a control

    No i made it with the Creator.
    here i uploded all the "project" source:
    Link to Download page

    Thank you very much!

  11. #11
    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: problem with Hebrew font in a control

    Hi,

    there is some strangeness inside you code (at least for me...). I still can say: use utf8 since Qt use that codec. Make sure you have configured Qt Creator to use utf8!
    Also QTextCodec was not used correct:
    Qt Code:
    1. void MainReader::on_pushButton_clicked()
    2. {
    3. QFile file(ui->lineEdit->text());
    4. if(file.open(QIODevice::ReadOnly | QIODevice::Text))
    5. {
    6. QTextStream in(&file);
    7. in.setCodec("Windows-1255");
    8. QString line = in.readAll();
    9. ui->textEdit->append(line);
    10. }
    11. }
    12.  
    13. void MainReader::on_pushButton_2_clicked()
    14. {
    15. ui->textEdit->append(trUtf8("נסיון"));
    16. }
    To copy to clipboard, switch view to plain text mode 

    and with the button no problem at all. And as a further suggestion: Have a look at the layout mechanism. QHBoxLayout etc.

  12. #12
    Join Date
    Feb 2010
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: problem with Hebrew font in a control

    1) Thank you very much.
    2) How can i configure my Creator to use UTF8?
    3) the code you written in Button 2 appended only gibberish...
    4) with the button on the right up corner, in Windows their is no problem, but in S60 his text in gibberish..

  13. #13
    Join Date
    Feb 2010
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: problem with Hebrew font in a control

    What is the chance that the UTF8 in Windows and S60 are different??
    i declared the name of the button like so:
    Qt Code:
    1. ui->pushButton_2->setText(QString::fromUtf8("\327\224"));
    To copy to clipboard, switch view to plain text mode 
    in Windows i got "ה"
    in S60 i got "ש"
    What the heck? what i am doing wrong???

Similar Threads

  1. Replies: 0
    Last Post: 16th December 2009, 09:45
  2. activeWindow control problem
    By batileon in forum Newbie
    Replies: 3
    Last Post: 17th October 2008, 07:44
  3. RightToLeft QTextEdit for Hebrew
    By hed in forum Qt Programming
    Replies: 6
    Last Post: 16th April 2008, 20:33
  4. Replies: 1
    Last Post: 25th December 2007, 10:35
  5. problem with spinbox control ?
    By vinod in forum Qt Programming
    Replies: 3
    Last Post: 19th April 2006, 19:58

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.