Results 1 to 3 of 3

Thread: How to jump from QGraphicsItem::keyPressEvent txt to a new QGraphicsItem

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to jump from QGraphicsItem::keyPressEvent txt to a new QGraphicsItem

    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:
    Qt Code:
    1. enum LAYERTYPE {
    2. DIV_ABSOLUTE = 50, /* position fixed x y*/
    3. DIV_AUTO,/* 51 */ /* auto floating */
    4. DIV_FLOAT,/* 52 */ /* left, right to parent */
    5. DIV_HEADER, /* 53 */ /* page header child s 51 */
    6. DIV_FOOTER /* 54 */ /* page footer */
    7. };
    To copy to clipboard, switch view to plain text mode 
    Last edited by patrik08; 28th June 2008 at 11:15. Reason: spelling error

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to jump from QGraphicsItem::keyPressEvent txt to a new QGraphicsItem

    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

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to jump from QGraphicsItem::keyPressEvent txt to a new QGraphicsItem

    Quote Originally Posted by aamer4yu View Post
    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
    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..

    Qt Code:
    1. void GraphicsView::RecordItem()
    2. {
    3. /*
    4. header
    5. QMap<int,DivDiagram*> auto_li; auto float layer order by Y
    6.   QMap<int,DivDiagram*> abso_li; absolute layer order by zindex
    7. */
    8. auto_li.clear();
    9. abso_li.clear();
    10. int ordersorting = 10; /* start */
    11. int absolutecount = 5000; /* start from fixed */
    12. QList<QGraphicsItem *> listing = scene->items(); /* scene all root item */
    13. for (int e=0;e<listing.size();e++) {
    14. DivDiagram *it = qgraphicsitem_cast<DivDiagram *>(listing[e]);
    15. if (it) {
    16. it->LayerHightChecks(); /* recalc document boundingrect */
    17. /* auto float div elements */
    18. if (it->Formats() != DivDiagram::DIV_ABSOLUTE ) {
    19. const int fromtop = it->pos().y() + 1;
    20. if (!auto_li[fromtop]) {
    21. auto_li.insert(fromtop,it);
    22. } else {
    23. auto_li.insert(fromtop + 1,it);
    24. }
    25.  
    26. } else {
    27. /* absolute fixed elements */
    28. absolutecount++;
    29. abso_li.insert(absolutecount,it);
    30. }
    31. }
    32. }
    33. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QGraphicsItem doesn't inherit QObject?
    By xyzt in forum Qt Programming
    Replies: 6
    Last Post: 26th September 2011, 14:59
  2. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31
  3. Snap-to grid on QGraphicsItem
    By hardgeus in forum Qt Programming
    Replies: 9
    Last Post: 28th April 2008, 16:22
  4. Force the painting of a QGraphicsItem
    By fabietto in forum Qt Programming
    Replies: 3
    Last Post: 2nd July 2007, 21:28
  5. Deleting a scene from QGraphicsItem mouseEvent
    By JonathanForQT4 in forum Qt Programming
    Replies: 5
    Last Post: 10th April 2007, 11:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.