i have a QgraphicsTextItem containing a QTextTable.
How can i resize the QGraphicsTextitem(like the object QGraphicsRectItem that use the function setRect())????
i know it has the function boundingRect() but i don't know how to resize it......
i have a QgraphicsTextItem containing a QTextTable.
How can i resize the QGraphicsTextitem(like the object QGraphicsRectItem that use the function setRect())????
i know it has the function boundingRect() but i don't know how to resize it......
you must only chance hi = hight & wi = widht
and update item
Qt Code:
{ }To copy to clipboard, switch view to plain text mode
but alert you can not go smaller a qgraphicstextitem document rect!
Qt Code:
{ if (_d) { /* _d = qtextdocument */ _d->adjustSize(); return Layout->frameBoundingRect(_d->rootFrame()); } else { } }To copy to clipboard, switch view to plain text mode
and qgraphicstextitem can only move xy if you point the mouse on document boundingRect()
this is one reason for my rewrite from qgraphicstextitem
http://www.qt-apps.org/content/show....?content=80234
remember parent event from mouse comming only if qtextdocument rect containt this area...
Last edited by patrik08; 21st May 2008 at 11:34.
i write the code to set the column width, but it isn't applied to the table....just the width applied in the constructor works......
this is my constructor:
Qt Code:
for(int i=0;i<2;i++) tableformat->setBorder(1); tableformat->setCellSpacing(0); tableformat->setCellPadding(0); tableformat->setColumnWidthConstraints(columnWidthVector); table = cursor->insertTable(2,2,*tableformat);To copy to clipboard, switch view to plain text mode
then i update the column width:
Qt Code:
int pos=X;//some position QVector<QTextLength> constraints =tableformat->columnWidthConstraints(); for (int i = 0; i < constraints.size(); i++) if (i == currCell.column()) tableformat->setColumnWidthConstraints(constraints);To copy to clipboard, switch view to plain text mode
Why i don't see the updated column width in my view???
I'm using the table into a QGraphicsTextItem.............thx
Here this run...
grep table on page
http://fop-miniscribus.googlecode.co...dataeditor.cpp
Qt Code:
void Layoutpainter::SetColumLarge() { if (textCursor().currentTable()) { int cellcoolcursoris = existingcell.column(); /* int value start from zero */ bool ok; tr("Point Length:"),Get_Cell_Width(tbforms,cellcoolcursoris), 1, 2000, 1, &ok); if (ok && LargeSet > 0) { QVector<QTextLength> constraints = tbforms.columnWidthConstraints(); for (int i = 0; i < constraints.size(); ++i) { if (i == cellcoolcursoris) { } } tbforms.setColumnWidthConstraints(constraints); textCursor().currentTable()->setFormat(tbforms); } } } { 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
I have this three doubt:
1)How can i set the height of each cell? I guess i have to change the cursor font character....
2)Is there any option that gives me the possibility to select a cell in a QTextTable but doesn't give me the possibility to insert Text?
3)I insert a QTextTable into a QGraphicsTextItem throw the function set document. My textItem's bounding rectangle is almost coincident with the textTable inside it. If a select all the table, the cursor position goes out of the table and if I insert a character, the table disappears.
How resolve?
I think that solving the second problem, i will also solve the third one.
You can set the widht from cell and widht from table , the height from cell depend from block format font and margin left,right,top,bottom QT set default margin 12point any direction ( i dont know why && i not found config to reset 0point ) but you can stop this margin on keyPressEvent check QTextBlock block = C_cursor.block(); margin and reformat
your own margin e padding...
sure ...2)Is there any option that gives me the possibility to select a cell in a QTextTable but doesn't give me the possibility to insert Text?
keyPressEvent
if (textCursor().currentTable()) {
return;
and
mousepress & release edit cell rectancle like code from
http://www.qt-apps.org/content/show....?content=80234
if you resize _doc to table rectangle also QTextDocument + only one table you can only select table
3)I insert a QTextTable into a QGraphicsTextItem throw the function set document. My textItem's bounding rectangle is almost coincident with the textTable inside it. If a select all the table, the cursor position goes out of the table and if I insert a character, the table disappears.
How resolve?.
+ _doc->documentLayout()->frameBoundingRect(_doc->rootFrame()) show you rect to stay on item..
Qt Code:
_doc->setHtml(tr("<p>Table<p>")); rootformats.setWidth(wi); rootformats.setBorder(0); /* + margin padding 0*/ Tframe->setFrameFormat(rootformats); DLayout = _doc->documentLayout();To copy to clipboard, switch view to plain text mode
But i suppose you can draw table only on a QGraphicsItem not on QGraphicsTextItem
have you a model QStandardItemModel from table data?
if yes expand this model to Qtextable like
http://doc.trolltech.com/4.2/richtext-calendar.html and draw it on QGraphicsItem paintevent ...
what for data contain this table to not edit?
Doubt dealing with the color of a cell.
When i color a cell's background i call this function:
Qt Code:
To copy to clipboard, switch view to plain text mode
while i call this other for the table background:
Qt Code:
To copy to clipboard, switch view to plain text mode
If I color a cell before coloring the whole table, the cell manteins its color....How change this behaviour??(This also happens in your(PATRIk08) program...)
Bookmarks