Results 1 to 2 of 2

Thread: QGraphicsItemGroup - draw as QPixmap

  1. #1
    Join Date
    Oct 2010
    Location
    Cracow,Bielsko-Biała/Polska
    Posts
    15
    Thanks
    3
    Platforms
    Unix/X11 Windows

    Default QGraphicsItemGroup - draw as QPixmap

    Hello.

    I created my own format for reading/writting objects from scene.
    It works fine, but when I try to create QPixmap by using QGraphicsItemGroup
    I have some problems.

    Qt Code:
    1. QPixmap pixmap(600, 150);
    2. QPainter painter(&pixmap);
    3.  
    4. ... loading data from file....
    5. QGraphicsItem* item = importers.getData().at(0);
    6. painter.setRenderHints(QPainter::Antialiasing);
    7. QGraphicsItemGroup* group = qgraphicsitem_cast<QGraphicsItemGroup*>(item);
    8.  
    9. BOOST_FOREACH(QGraphicsItem* itemc, group->children()) {
    10. itemc->paint(&painter, &opt);
    11. }
    12.  
    13. scene->addPixmap(pixmap);
    To copy to clipboard, switch view to plain text mode 

    Below code used to store information:

    Qt Code:
    1.  
    2. ds << path();
    3. QTransform parentTransforms;
    4. if(parentItem())
    5. parentTransforms = parentItem()->transform();
    6.  
    7. ds << parentTransforms;
    8. ds << transform();
    To copy to clipboard, switch view to plain text mode 

    Below code used to load information:

    Qt Code:
    1. QTransform parentTransforms;
    2. QTransform transforms;
    3.  
    4. ds >> path >> parentTransforms >> transforms;
    5.  
    6. setPath(path);
    7.  
    8. setTransform(parentTransforms);
    9. setTransform(transforms, true);
    To copy to clipboard, switch view to plain text mode 

    Problem: QPainterPath starts drawing from position ...x=420(before drawing moveTo is called)

    What kind of informations should I save for QPainterPath, to restore it corectly ?
    Thanks, for reply.
    Last edited by Leszek; 24th October 2010 at 21:53. Reason: updated contents

  2. #2
    Join Date
    Oct 2010
    Location
    Cracow,Bielsko-Biała/Polska
    Posts
    15
    Thanks
    3
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItemGroup - draw as QPixmap

    This problem was reolved in thread
    http://www.qtcentre.org/threads/3537...dren.?p=163407

Similar Threads

  1. add(draw) an icon(or image) to a QPixmap?
    By ascii in forum Qt Programming
    Replies: 4
    Last Post: 20th November 2008, 12:44
  2. Replies: 4
    Last Post: 28th August 2008, 13:13
  3. Replies: 1
    Last Post: 21st August 2008, 07:44
  4. Add two QGraphicsItemGroup
    By ashishsaryar in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2008, 18:00
  5. Replies: 5
    Last Post: 9th April 2007, 14:26

Tags for this Thread

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.