Results 1 to 2 of 2

Thread: cell division problem on QTextDocument

Threaded 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 cell division problem on QTextDocument

    I create QTextTable and populate it with data.
    Then I print out table via using QTextDocument.

    I can print out table successfully. But in some pages cells are divided.
    For example If my cell is three lines, first line of table is in bottom of 5. page, second and third lines of table are in top of 6. page.
    How do I get rid of this problem?

    I create QTextTable:
    Qt Code:
    1. TextDocument *document=new QTextDocument(this);
    2. QTextCursor cursor(document);
    3. cursor.movePosition(QTextCursor::Start);
    4.  
    5. QTextTableCellFormat cellFormat;
    6. cellFormat.setLeftPadding(7);
    7. cellFormat.setRightPadding(7);
    8. cellFormat.setTopPadding(2);
    9.  
    10. QBrush blackBrush(Qt::SolidPattern);
    11. QTextTableFormat tableFormat;
    12. tableFormat.setAlignment(Qt::AlignLeft);
    13. tableFormat.setBorderBrush(blackBrush);
    14. tableFormat.setBorder(0.5);
    15. tableFormat.setCellSpacing(0);
    16. tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
    17. tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
    18. QTextTable *table = cursor.insertTable(100,10,tableFormat);
    19.  
    20. QTextTableCell cell=table->cellAt(1,0);
    21. cell.setFormat(cellFormat);
    22. cell.firstCursorPosition().insertText("this is long sentence");
    23. ....
    To copy to clipboard, switch view to plain text mode 

    And I print out:

    Qt Code:
    1. QPrinter printer;
    2. printer.setOrientation(QPrinter::Landscape);
    3. printer.setPageMargins(10,10,10,50,QPrinter::Millimeter);
    4. QPrintDialog *dlg = new QPrintDialog(&printer, this);
    5. if (dlg->exec() != QDialog::Accepted)
    6. return;
    7. document->print(&printer);
    To copy to clipboard, switch view to plain text mode 

    sorry for my English
    Last edited by sipahi; 6th February 2013 at 20:56.

Similar Threads

  1. Replies: 5
    Last Post: 5th November 2010, 17:26
  2. Scale division problem
    By Indalo in forum Qwt
    Replies: 0
    Last Post: 2nd December 2009, 08:36
  3. Parse QTextBlock from QTextDocument problem
    By patrik08 in forum Qt Programming
    Replies: 0
    Last Post: 5th April 2008, 08:26
  4. QTextDocument Image resource problem
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 15:28
  5. Replies: 0
    Last Post: 13th July 2007, 22:45

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.