Results 1 to 6 of 6

Thread: QTextTable horizontal alignment of a cell

  1. #1
    Join Date
    May 2006
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QTextTable horizontal alignment of a cell

    Hello!

    I would like to ask you, if you know how to horizontal align a text in a cell of a QTextTable?

    Thank you,
    Willi

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTextTable horizontal alignment of a cell

    J-P Nurmi

  3. #3
    Join Date
    May 2006
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTextTable horizontal alignment of a cell

    Yes, but this works only for the whole table.
    I would like to have a table where the text of the first column is aligned to the left, and the second column is aligned right...

  4. #4
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    4
    Thanked 5 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTextTable horizontal alignment of a cell

    Did you already find a solution? I'm trying this as well with no succes until now...

  5. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTextTable horizontal alignment of a cell

    http://doc.trolltech.com/main-snapsh...Alignment-enum


    on new QTextTableCellFormat Qt 4.4. you can set padding -
    setTopPadding ( qreal padding )
    setRightPadding ( qreal padding )
    setBottomPadding ( qreal padding )
    setLeftPadding ( qreal padding )

    and you can format textblock inside cell


    Qt Code:
    1. void QTextTableCell::setFormat ( const QTextCharFormat & format )
    To copy to clipboard, switch view to plain text mode 


    http://doc.trolltech.com/main-snapsh...harformat.html
    http://doc.trolltech.com/main-snapsh...ellformat.html
    http://doc.trolltech.com/main-snapsh...tablecell.html


    A fast way to generate document on qt after 4.5 is xslt!

    xml data + style .. or db to xml + style xslt

    Qt Code:
    1. #if QT_VERSION >= 0x040500
    2. QDateTime timer1( QDateTime::currentDateTime() );
    3. StreamBuf *buf = new StreamBuf();
    4. QXmlQuery xquery(QXmlQuery::XSLT20);
    5. xquery.setFocus(QUrl("http://www.qtcentre.org/forum/external.php?type=RSS2"));
    6. xquery.bindVariable("unixtime", QVariant(timer1.toTime_t()));
    7. xquery.bindVariable("ddate", QVariant(timer1.toString()));
    8. xquery.bindVariable("ddformat", QVariant(QDir::homePath () ));
    9. xquery.setQuery(QUrl("http://fop-miniscribus.googlecode.com/svn/trunk/doc/draw_paper/browser_rss.xsl"));
    10. xquery.evaluateTo(buf->device());
    11. _doc->setHtml ( buf->data() );
    12. ////////////buf->PutOnFile( "ddebughtml.html" );
    13. #endif
    To copy to clipboard, switch view to plain text mode 


    try to build -> http://fop-miniscribus.googlecode.co...oc/draw_paper/
    Last edited by patrik08; 13th October 2008 at 20:36.

  6. #6
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    4
    Thanked 5 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTextTable horizontal alignment of a cell

    Thanks for your reply.

    for me
    Qt Code:
    1. QTextBlockFormat rightAlignment;
    2. rightAlignment.setAlignment(Qt::AlignRight);
    3.  
    4. QTextTable * testTable = cursor.insertTable(4,4);
    5. testTable->cellAt(0,0).firstCursorPosition().setBlockFormat(rightAlignment);
    6. testTable->cellAt(0,0).lastCursorPosition().insertText("test");
    7. // etc.
    To copy to clipboard, switch view to plain text mode 

    did the trick. Previously I was unsuccesfully trying to do an insertBlock() at the cursorposition, resultiing in two textblocks per cell.

  7. The following 5 users say thank you to maartenS for this useful post:

    Cortex (23rd October 2009), Ishmael (24th September 2009), jml (9th July 2012), Netwiz (30th April 2010), rajen (5th May 2009)

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.