Results 1 to 13 of 13

Thread: Getting HTML table cell width

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2013
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Getting HTML table cell width

    thank you for your patient and assistance @wysota.
    I am new in Qt and I do not know completely what Qt can do.

    Basically I am trying to create two separate tables which have exactly same size and number of columns.
    And then print out two tables. But contents of tables are different. Because of that widths of columns become different.
    And also I don not know how can I trigger the layouting functionality.
    Last edited by sipahi; 2nd February 2013 at 10:44.

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Getting HTML table cell width

    In your first post you created a table in html with a width of 100%.
    You can do the same for every cell in a row. Set them all to a fixed pixel value or percentage, except for one column. That one will fill up the remaining space in a row.
    Also, you don't have to do it for every row, as all cells in a column will, normally, have the same width.

    All this can be done with an element like <td width=100> or using css stylesheets. You know how to use stylesheets as you used it in the original table definition, class="tbl".

    The main difference in this approach is that you now set a width instead of trying to get it from a renderer that is not yet in action (as others told you before).

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Getting HTML table cell width

    Quote Originally Posted by sipahi View Post
    I am new in Qt and I do not know completely what Qt can do.
    It's not about Qt. HTML holds information about the logical structure of a document and not its physical attributes. Only when the document is displayed in some kind of browser, it gains those physical attributes but only for particular input parameters like the browser's default font, window size, device resolution, CSS definitions and so on.

    Basically I am trying to create two separate tables which have exactly same size and number of columns.
    And then print out two tables. But contents of tables are different. Because of that widths of columns become different.

    And also I don not know how can I trigger the layouting functionality.
    It depends on the document engine you are using. For HTML you can use WebKit, for QTextDocument you can use QAbstractTextDocumentLayout and QTextDocument itself. You can iterate over all rows in the two tables you have, find a maximum width cells in your particular column occupy and then set that width on those columns explicitly (if the engine allows it).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. .csv format cell width
    By bostero22 in forum Qt Programming
    Replies: 1
    Last Post: 3rd September 2010, 23:06
  2. Replies: 1
    Last Post: 25th May 2010, 14:44
  3. QTreeView cell as table
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2009, 09:45
  4. Setting cell width in QHBoxLayout
    By EricF in forum Qt Programming
    Replies: 5
    Last Post: 13th December 2007, 15:42
  5. QTextImageFormat HTML not write <img width= height>
    By patrik08 in forum Qt Programming
    Replies: 9
    Last Post: 8th February 2007, 01:59

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
  •  
Qt is a trademark of The Qt Company.