PDA

View Full Version : Qt supported html subset "table" element RTL problem



kalma
8th March 2012, 05:19
Hi

I am using Qt 4.7.4 Win.
My problem is that the RTL feature seems not to work for the HTML “table” element.
e.g. the following works fine for LTR languages


QString htmtext("<table>"
"<tr><td>name1<td>name2....")

But I have to work around this to have it work for RTL “Arabic” as follows:


QString htmtext("<table>"
"<tr><td>name2<td>name1....")

Very annoying when working with big table.

Using dir=“rtl” proved to be of no use here too; is it a bug or Qt works this way?


here is a sample of the main part that I keep tweaking:



#include <QTextBrowser>

void showtable(int lang)
{
QtextBrowser *textBrowser = new QtextBrowser;
QString report;

switch (lang)
{
case 0://Arabic
{
textBrowser->setLayoutDirection(Qt::RightToLeft);// works fine for layout only but not RTL text rendered insude QTextBrowser

//-----------table header
report = "<table width=\"100%\" dir=rtl align=right border=1 cellspacing=0 cellpadding=1>" //RTL bug???
"<tr><td align=center colspan=3><H3>"+tr("Media Details")+"<font color=red><b> [</b>"+name+"<b>]</b></font>"
"<tr><td align=center bgcolor=\"#EBEBEB\" width=\"50%\"><b>"+tr("Details")+"</b>"
"<td align=center bgcolor=\"#EBEBEB\" width=\"20%\"><b>"+tr("Logo")+"</b>"//make nicer
//--------------details
"<tr><td align=right>"+name+"<td align=right><b>"+tr("Name")+"<td rowspan=4 align=center valign=middle>./medialogo.png"
"<tr><td align=right>"+"Qtland"+"<td align=right><b>"+tr("Country")+
"<tr><td align=right>"+"info"+"<td align=right><b>"+tr("Content")+
"<tr><td align=right>"+"programming"+"<td align=right><b>"+tr("Genre")+
"<tr><td align=right>"Owner"<td align=right><b>"+tr("Ownership")+"<td></table><p><br>";
break;
}
case 1://English
{
//-----------table header
report = "<table width=\"100%\" border=1 cellspacing=0 cellpadding=1>" //
"<tr><td align=center colspan=3><H3>"+tr("Media Details")+"<font color=red><b> [</b>"+name+"<b>]</b></font>"
"<tr><td align=center bgcolor=\"#EBEBEB\" width=\"20%\"><b>"+tr("Logo")+"</b>"//make this nicer
"<td align=center bgcolor=\"#EBEBEB\" width=\"50%\"><b>"+tr("Details")+"</b>"
//--------------details
"<tr><td align=center valign=middle>./medialogo.png<td><b>"+tr("Name")+"<td>"+name+
"<tr><td><b>"+tr("Country")+"<td>"+"Qtland"+
"<tr><td><b>"+tr("Content")+"<td>"+"info"+
"<tr><td><b>"+tr("Genre")+"<td>"+"programming"+
"<tr><td><td><b>"+tr("Ownership")+"<td>"Owner"</table><p><br>";
break;
}
}//switch

textBrowser->setText(report);
}