Results 1 to 10 of 10

Thread: i am facing a problem with QTextEdit!!!

  1. #1
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Question i am facing a problem with QTextEdit!!!

    hello,
    i connected to a database that contains text which is non english language(right to left language) i used the following code to show the text:

    mainText->setText(query.value(0).toString());

    but when the text appears on the QtextEdit it appears with strange characters
    i tried the following experiments and they failed

    mainText->setText(QString::fromLocal8Bit(query.value(0).toS tring()));

    mainText->setText(query.value(0).tochar());

    can any body help me???
    thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: i am facing a problem with QTextEdit!!!

    Quote Originally Posted by mismael85 View Post
    mainText->setText(query.value(0).toString());
    This should be enough provided that you have a font that contains all required characters.

    How did you insert data into the database?

  3. #3
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: i am facing a problem with QTextEdit!!!

    i inserted the data by keyboard.
    note i faced this problem before when i tried to open file which is contained in a folder named by a right to left laguage when i tried to take the file name from argv[1] variable
    of the main function and i solved this problem by using the following code
    QString::fromLocal8Bit(arvg[1]);
    and the problem is solved but when i tried to do this with current situation the compiler says
    error C2664: 'QString::fromLocal8Bit' : cannot convert parameter 1 from 'QString' to 'const char *'
    !!!!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: i am facing a problem with QTextEdit!!!

    Quote Originally Posted by mismael85 View Post
    i inserted the data by keyboard.
    Are you sure that the data in the database is in correct encoding? What database do you use? What encoding does it use? What encoding does your system use? What application did you use to enter the data?

    Quote Originally Posted by mismael85 View Post
    i tried to take the file name from argv[1] variable
    of the main function and i solved this problem by using the following code
    QString::fromLocal8Bit(arvg[1]);
    That's a different case. Qt should get data from the database in correct form all by itself.

  5. #5
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: i am facing a problem with QTextEdit!!!

    Are you sure that the data in the database is in correct encoding?
    yes i am sure it is a plain text.
    What database do you use?
    i am using microsoft access database.
    What encoding does your system use?
    i am using windows xp
    What application did you use to enter the data?
    i am using microsoft access.

  6. #6
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: i am facing a problem with QTextEdit!!!

    i made a new database and i entered right to left text. and showed it to QTextEdit
    and it appears successfully.
    but with my old database which is made by MS access 97 the text are not appears
    correctly.

  7. #7
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: i am facing a problem with QTextEdit!!!

    when i converted the database to MS access 2003 the text displayed fine.
    i don't know why!!!
    but i should operate on access 97 because i don't own the database i am just using it.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: i am facing a problem with QTextEdit!!!

    Quote Originally Posted by mismael85 View Post
    when i converted the database to MS access 2003 the text displayed fine.
    So either data in the other database uses wrong encoding or there is something wrong with the ODBC driver for that database and most likely it's the latter. For example Qt might not be able to negotiate the encoding with the driver.

    Can you see properly the data you insert into the database using Qt?

  9. #9
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: i am facing a problem with QTextEdit!!!

    i tried to insret data using Qt to the database that are converted to access 2002.
    but only that data are displayed with strange carachters.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: i am facing a problem with QTextEdit!!!

    Quote Originally Posted by mismael85 View Post
    but only that data are displayed with strange carachters.
    How do you insert that data then?

Similar Threads

  1. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  2. repaint problem in QTextEdit
    By kennyxing in forum Qt Programming
    Replies: 2
    Last Post: 10th November 2006, 08:49
  3. QTextEdit problem
    By vijay anandh in forum Qt Programming
    Replies: 1
    Last Post: 14th July 2006, 11:56
  4. Facing problem with tool bar icons
    By jnana in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 08:37
  5. Problem with inserting text into QTextEdit
    By xorrr in forum Qt Programming
    Replies: 0
    Last Post: 6th February 2006, 11:45

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.