PDA

View Full Version : i am facing a problem with QTextEdit!!!



mismael85
7th March 2008, 22:44
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).toSt ring()));

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

can any body help me???
thank you.

jacek
7th March 2008, 23:18
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?

mismael85
8th March 2008, 14:32
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 *'
!!!!

jacek
8th March 2008, 14:38
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?


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.

mismael85
8th March 2008, 18:02
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.

mismael85
8th March 2008, 18:17
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.

mismael85
8th March 2008, 18:31
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.

jacek
8th March 2008, 23:11
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?

mismael85
9th March 2008, 18:45
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.

jacek
10th March 2008, 19:06
but only that data are displayed with strange carachters.
How do you insert that data then?