[Qt-interest] Simple QTextTable border dificulty
Israel Brewster
israel at frontierflying.com
Sat Feb 21 01:03:16 CET 2009
I am trying to make a table in a QTextDocument that has simple single
thin black lines between the cells. Unfortunately I am having some
difficulty accomplishing this - some of the created lines are as
desired (such as the left border on the 8 cell in the attached screen
shot), but others (such as the top and right borders on said cell)
appear doubled. The bottom border is Ok, but does appear somewhat
heaver than the rest. The code that created this table is shown below.
How can I fix this? Thanks.
QTextDocument *document=new QTextDocument;
QTextCursor cursor(document), cellCursor;
QTextFrame *topFrame = cursor.currentFrame();
QTextTableCellFormat cellFormat;
cellFormat.setLeftPadding(7);
cellFormat.setRightPadding(7);
QBrush blackBrush(Qt::SolidPattern);
QTextTableFormat tableFormat;
tableFormat.setAlignment(Qt::AlignLeft);
tableFormat.setBorderBrush(blackBrush);
tableFormat.setBorder(.5); //using .5 because I figure the left border
of one cell plus the right border of the next should make 1
tableFormat.setCellSpacing(0); //I want no space between the cells.
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
tableFormat.setAlignment(Qt::AlignLeft);
QVector<QTextLength> constraints;
for(int i=0;i<15;i++)
constraints<< QTextLength(QTextLength::PercentageLength,6.6);
tableFormat.setColumnWidthConstraints(constraints);
table = cursor.insertTable(1,15,tableFormat);
I then loop through each cell doing something like the following:
cell=table->cellAt(0,0);
cell.setFormat(cellFormat);
cellCursor=cell.firstCursorPosition();
cellCursor.insertText("Day ");
-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: badBorders.pdf
Type: application/pdf
Size: 53075 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090220/f470759b/attachment.pdf
More information about the Qt-interest-old
mailing list