PDA

View Full Version : How to jump from QGraphicsItem::keyPressEvent txt to a new QGraphicsItem



patrik08
28th June 2008, 11:11
I have a problem on my QGraphicsScene

the QGraphicsScene have many page section/Virtual draw as printer size
"A4 (210 x 297 mm, 8.26 x 11.7 inches , QPrinter::A4; or other user define size.

By typing text on Layer QGraphicsItem i have any time the correct QRectF from page. And avaiable line to write.
Now how i can jump to a new QGraphicsItem (as new page A4) and focus him? Any idea?

Any Page contain many textlayer of type:


enum LAYERTYPE {
DIV_ABSOLUTE = 50, /* position fixed x y*/
DIV_AUTO,/* 51 */ /* auto floating */
DIV_FLOAT,/* 52 */ /* left, right to parent */
DIV_HEADER, /* 53 */ /* page header child s 51 */
DIV_FOOTER /* 54 */ /* page footer */
};

aamer4yu
28th June 2008, 15:11
You can have a array of graphics item in the scene. But show only one graphicsitem at a time.
On key press, hide the current and show the desired.

Hope I got ur requirement right :D

patrik08
28th June 2008, 16:31
You can have a array of graphics item in the scene. But show only one graphicsitem at a time.
On key press, hide the current and show the desired.
Hope I got ur requirement right :D

I have only a QMap and item is sort by Pos Y.. and on save as page each Layer go record
by this order .... to compose HTML code....
QTextDocument dont can render <div> tag on this case each layer is a <div>
If i use this only as html export i not having problem, but export as other format like xsl-fo or only print line is cut on midle of a block or image ...

I suppose the better way is to expand a QGraphicsItem as page and fill child layer div just having place .... and after emit to scene to init a new page.. to next layer...
Or how you plan your this?

Not display all page is not a clean solution..




void GraphicsView::RecordItem()
{
/*
header
QMap<int,DivDiagram*> auto_li; auto float layer order by Y
QMap<int,DivDiagram*> abso_li; absolute layer order by zindex
*/
auto_li.clear();
abso_li.clear();
int ordersorting = 10; /* start */
int absolutecount = 5000; /* start from fixed */
QList<QGraphicsItem *> listing = scene->items(); /* scene all root item */
for (int e=0;e<listing.size();e++) {
DivDiagram *it = qgraphicsitem_cast<DivDiagram *>(listing[e]);
if (it) {
it->LayerHightChecks(); /* recalc document boundingrect */
/* auto float div elements */
if (it->Formats() != DivDiagram::DIV_ABSOLUTE ) {
const int fromtop = it->pos().y() + 1;
if (!auto_li[fromtop]) {
auto_li.insert(fromtop,it);
} else {
auto_li.insert(fromtop + 1,it);
}

} else {
/* absolute fixed elements */
absolutecount++;
abso_li.insert(absolutecount,it);
}
}
}
}