Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt supported html subset, RTL problem
Forum Update on Monday, May 27th 2025

Qt supported html subset, RTL problem

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kalma
    wrote on 7 Mar 2012, 15:13 last edited by
    #1

    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?

    please help;
    thanks

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on 8 Mar 2012, 03:40 last edited by
      #2

      Maybe it's a bug? Can you paste a minimal testcode? Also, does it happen with webkit?

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kalma
        wrote on 8 Mar 2012, 04:46 last edited by
        #3

        Hi! thanks for the reply
        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
                    {
                    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><img src='./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><img src='./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);
        

        }
        @

        I didn't test it against Webkit.

        Thanks in advance

        1 Reply Last reply
        0

        1/3

        7 Mar 2012, 15:13

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved