Hi all.
I want to place two text blocks on one line in QTextEditor. I have tried several combinations with QTextFrame and QTextCursor but it is useless(
Code: http://pastebin.com/d82d4579
I want blabla2 with border and blabla near it.
Hi all.
I want to place two text blocks on one line in QTextEditor. I have tried several combinations with QTextFrame and QTextCursor but it is useless(
Code: http://pastebin.com/d82d4579
I want blabla2 with border and blabla near it.
Why not wrap them into a table?
So, i have tried code below. But when i use this method columns don't save their width. Any ideas?
Qt Code:
QVector<QTextLength> columnWidth; for(int i=0; i<15; i++) { if(i==0) if(i>0 && i<10) else if(i>9 && i<12) else if(i==12 || i==14) else if(i==13) } QTextTableFormat numberTableFormat; numberTableFormat.setBorder(0); numberTableFormat.setCellSpacing(-1); numberTableFormat.setColumnWidthConstraints(columnWidth); cursor = mainTable->cellAt(0,2).firstCursorPosition(); tempFormat.setBorder(1); cursor.insertFrame(tempFormat); cursor.insertText("some text");To copy to clipboard, switch view to plain text mode
Try setting the width also for the whole table.
I cannot find method to do this. Can you give me link?
The table is a frame so you can use QTextFrameFormat::setWidth() and apply it to the table.
I have tried this. But it doesn't work.
Qt Code:
QVector<QTextLength> columnWidth; for(int i=0; i<15; i++) { if(i==0) if(i>0 && i<10) else if(i>9 && i<12) else if(i==12 || i==14) else if(i==13) } QTextTableFormat numberTableFormat; numberTableFormat.setBorder(0); numberTableFormat.setCellSpacing(-1); numberTableFormat.setColumnWidthConstraints(columnWidth); numberTableFormat.setBorderBrush(brush); //UPDATE numberTableFormat.setWidth(824.25); //SECOND OPTION: //mainTable->format().setWidth(824.25); cursor = mainTable->cellAt(0,2).firstCursorPosition(); tempFormat.setBorder(1); cursor.insertFrame(tempFormat); cursor.insertText("1");To copy to clipboard, switch view to plain text mode
Try building on this code:
Qt Code:
QTextTableFormat tfmt; tfmt.setBorder(0); cursor = table->cellAt(0,0).firstCursorPosition(); tfmt.setBorder(1); inner->cellAt(0,0).firstCursorPosition().insertText("blabla2"); table->cellAt(0,1).firstCursorPosition().insertText("blabla");To copy to clipboard, switch view to plain text mode
Garfeild (22nd April 2008)
Thnx! It's working.
I have new problem. I need to set cell height. I have tried to use QTextFrameFormat::setHeight(qreal height) but cells haven't resized. Also i tried to set height for whole table.
is not possibel!
only if you subclass QAbstractTextDocumentLayout and on a protected function
you can insert all your elements ... structure and draw method...void QAbstractTextDocumentLayout::drawInlineObject ( QPainter * painter, const QRectF & rect, QTextInlineObject object, int posInDocument, const QTextFormat & format ) [virtual protected]
Called to draw the inline object object on the given painter within the rectangle specified by rect using the text format specified by format. posInDocument specifies the position of the object within the document.
only Cell_Width is possibel to set ... if you work on layer based
table are not needet have a look on http://code.google.com/p/fop-miniscribus/
and his xhtml export .... !not IE
Qt Code:
{ qreal notfound = 0; QVector<QTextLength> constraints = TableFormat.columnWidthConstraints(); for (int i = 0; i < constraints.size(); ++i) { if (i == position) { return langecell.rawValue(); } } } return notfound; }To copy to clipboard, switch view to plain text mode
to insert other parameter to QTextBlock, QTextTableFormat , QTextImageFormat ... you can use QTextFormat::propertyi use this to save image data .... and i can save doc and image on not GUI QThread whitout use QPixmap.
Qt Code:
............. Pics = block.toImageFormat(); if (Pics.isValid()) { QString titles; if (!inline_img_info.isNull()) { SPics pic = inline_img_info.value<SPics>(); } }To copy to clipboard, switch view to plain text mode
Bookmarks