How i can subclass QTextTableCell to paint only border bottom 1pt black solid? ( or only left , top .... )
ist this possibel ?

I suppose to append after on HTML QTextDocument tohtml td style
border-bottom:1px solid black;

Qt Code:
  1. void Fop_Handler::ParserTable( const QDomElement e , QTextDocument * d , Fop_Layer * layer , int CursorPositon )
  2. {
  3.  
  4. if (FoTag(e) != TABLE_TAG) {
  5. return;
  6. }
  7.  
  8. Fop_Block *foppi = new Fop_Block(imagecounter,e,"fo:table"); /* grep current source to play */
  9. qreal tableborderborder = TakeOneBorder(e);
  10. qreal tablewidth = Unit(e.attribute ("width",QString("0")));
  11. QDomElement co = e.parentNode().toElement();
  12. QTextCursor Tcursor = QTextCursor(d);
  13. bool IsCorrectCursor = Tcursor.movePosition(QTextCursor::End);
  14. int mappos = Tcursor.position(); /* last position from last cursor on class ! */
  15.  
  16. QTextCursor cellCursor; /* new cursor only for cell tabbing */
  17. QString tatype = e.attribute( "table-layout" ); /* on attribute root table */
  18. QStringList coolsizes; /* grep column size in pt cm mm ecc... */
  19. coolsizes.clear();
  20. QDomElement bodytable = e.firstChildElement("fo:table-body");
  21. int rowCounter = 0;
  22. int columnCounter = 0;
  23. QDomElement column = e.firstChildElement("fo:table-column");
  24. while (!column.isNull()) {
  25. const QString sizefromcool = column.attribute( "column-width" );
  26. if (sizefromcool.size() > 0) {
  27. coolsizes.append(sizefromcool); /* append unit widht string 22pt */
  28. }
  29. column = column.nextSiblingElement("fo:table-column");
  30. }
  31.  
  32. if (coolsizes.size() > 0) {
  33. columnCounter = coolsizes.size();
  34. }
  35.  
  36. QDomElement rows = bodytable.firstChildElement("fo:table-row");
  37. while (!rows.isNull()) {
  38. rowCounter++;
  39. rows = rows.nextSiblingElement("fo:table-row");
  40. }
  41. if (rowCounter < 1) {
  42. //////qDebug() << "### false row? " << columnCounter << " list" << coolsizes;
  43. return;
  44. }
  45. ////////qDebug() << "### true row " << columnCounter << " list" << coolsizes;
  46. /* #########################base table #######################################*/
  47. QTextTable *qtable = Tcursor.insertTable( rowCounter, columnCounter );
  48. ///////qDebug() << "### parse table... ";
  49. ////////qDebug() << "### rowCounter " << rowCounter;
  50. ////////qDebug() << "### columnCounter " << columnCounter;
  51. QTextTableFormat tableFormat;
  52. QString tbg = bodytable.attribute("background-color");
  53.  
  54. if (tablewidth !=0) {
  55. tableFormat.setWidth ( QTextLength ( QTextLength::FixedLength, tablewidth ) );
  56. ///////tableFormat.setHeight ( QTextLength ( QTextLength::FixedLength, tablewidth ) );
  57. }
  58. qreal borderDik = TakeOneBorder(bodytable);
  59. ////////qDebug() << "### table borderDik " << borderDik; /* qt4 4.3 bug unable to set table border on QGraphicsTextItem */
  60. if (!tbg.isEmpty()) {
  61. tableFormat.setBackground ( QColor(tbg) );
  62. }
  63. tableFormat.setBorder(borderDik);
  64. tableFormat.setCellSpacing(Unit(bodytable.attribute ("cell-space",QString("0"))));
  65. tableFormat.setCellPadding(TakeOnePadding(bodytable));
  66.  
  67.  
  68. /* colums on mm cm pt <-> */
  69. if (coolsizes.size() > 0) {
  70. tableFormat.clearColumnWidthConstraints();
  71. QVector<QTextLength> constraints;
  72. for (int i = 0; i < coolsizes.size(); ++i) {
  73. const qreal cellmesure = Unit(coolsizes.at(i));
  74. constraints.insert(i,QTextLength(QTextLength::FixedLength, cellmesure ));
  75. }
  76. tableFormat.setColumnWidthConstraints(constraints);
  77. }
  78.  
  79. if (tatype == "fixed") {
  80. tableFormat.setAlignment ( Qt::AlignLeft );
  81. } else {
  82. tableFormat.setAlignment ( Qt::AlignJustify );
  83. }
  84.  
  85. int qlistlargeNr = -1; /* cell and row count from 0 */
  86. QDomElement setrows = bodytable.firstChildElement("fo:table-row");
  87. while (!setrows.isNull()) {
  88. int is_spancol = 0;
  89. int startStorno = 0;
  90. int stopStorno = 0;
  91. bool bypassisactive = false;
  92. qlistlargeNr++;
  93. QTextBlockFormat tdformat;
  94. tdformat.setBottomMargin(0);
  95. tdformat.setTopMargin(0);
  96. QDomElement columnElement = setrows.firstChildElement(); /* sub element from row */
  97. int columnCounter = -1; /* cell and row count from 0 */
  98.  
  99. while ( !columnElement.isNull() ) {
  100. if ( columnElement.tagName().toLower() == "fo:table-cell" ) {
  101. columnCounter++;
  102.  
  103.  
  104.  
  105. is_spancol = columnElement.attribute( "number-columns-spanned" ).trimmed().toInt();
  106. if (is_spancol > 1) {
  107. for (int i = 0; i < is_spancol; ++i) {
  108. QTextTableCell cellstart = qtable->cellAt( qlistlargeNr , columnCounter + i);
  109. QTextCharFormat firster = cellstart.format();
  110. if (!columnElement.attribute("background-color").isEmpty()) {
  111. firster.setBackground(QColor(columnElement.attribute("background-color")));
  112. }
  113. cellstart.setFormat(firster);
  114. }
  115. /* point to last cell number-columns-spanned to fill text */
  116. qtable->mergeCells ( qlistlargeNr ,columnCounter,1,is_spancol);
  117. cell = qtable->cellAt( qlistlargeNr , columnCounter );
  118.  
  119. } else {
  120. cell = qtable->cellAt( qlistlargeNr , columnCounter );
  121. }
  122.  
  123. Tcursor = cell.firstCursorPosition();
  124. const qreal cellpadding = Unit(columnElement.attribute ("padding",QString("0")));
  125. const qreal cellwidht = Get_Cell_Width(tableFormat,columnCounter);
  126.  
  127.  
  128. /* paint cell Background and table border here */
  129. QTextCharFormat existformat = cell.format();
  130. if (!columnElement.attribute("background-color").isEmpty()) {
  131. existformat.setBackground(QColor(columnElement.attribute("background-color")));
  132. }
  133. existformat.setToolTip ( foppi->Get_XML() );
  134. cell.setFormat(existformat);
  135.  
  136. Tcursor = cell.firstCursorPosition();
  137. int FirstcellInitCursor = Tcursor.position();
  138.  
  139. int blocksDD = 0;
  140. QDomElement cellinside = columnElement.firstChildElement("fo:block");
  141. while ( !cellinside.isNull() ) {
  142. blocksDD++;
  143. if (blocksDD == 1) {
  144. ParserParagraph(cellinside,d,layer,FirstcellInitCursor,true);
  145. } else {
  146. ParserParagraph(cellinside,d,layer,CursorStatementPosition,true);
  147. }
  148.  
  149. cellinside = cellinside.nextSiblingElement("fo:block");
  150. }
  151.  
  152.  
  153. }
  154. columnElement = columnElement.nextSiblingElement();
  155. }
  156.  
  157.  
  158.  
  159. setrows = setrows.nextSiblingElement("fo:table-row");
  160. }
  161.  
  162.  
  163.  
  164. qtable->setFormat( tableFormat );
  165. ActualBackgroundColor = QString(default_background); /* reset color background */
  166. CursorStatementPosition = 0; /* go to end document ! */
  167.  
  168. }
To copy to clipboard, switch view to plain text mode