Results 1 to 4 of 4

Thread: adding QPixmap to scene

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Nashville Tn.
    Posts
    53
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default adding QPixmap to scene

    i have copied from the drap and drop demo :

    Qt Code:
    1. void printcal::dropEvent(QDropEvent *event)
    2.  
    3. {
    4. if (event->mimeData()->hasFormat("application/x-dnditemdata")) {
    5. QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
    6. QDataStream dataStream(&itemData, QIODevice::ReadOnly);
    7.  
    8.  
    9.  
    10. QPixmap pixmap;
    11. QPoint offset;
    12. dataStream >> pixmap >> offset;
    13.  
    14. QLabel *newIcon = new QLabel(this);
    15.  
    16. newIcon->setPixmap(pixmap);
    17. newIcon->move(event->pos() - offset);
    18. newIcon->show();
    19. newIcon->setAttribute(Qt::WA_DeleteOnClose);
    20.  
    21.  
    22.  
    23. if (event->source() == this) {
    24. event->setDropAction(Qt::MoveAction);
    25. event->accept();
    26.  
    27.  
    28.  
    29.  
    30. } else {
    31. event->acceptProposedAction();
    32. }
    33. } else {
    34. event->ignore();
    35. }
    36. }
    To copy to clipboard, switch view to plain text mode 

    i see the graphic on the scene in the view but

    how do i add the pixmap to the Graphics Scene ? I have tried scene->addPixmap(pixmap) , , addItem, addWidget etc... pls help.

    i am doing this so i can print the scene with the graphic .
    Last edited by wysota; 6th June 2009 at 00:14. Reason: missing [code] tags

Similar Threads

  1. Adding item to scene
    By lni in forum Qt Programming
    Replies: 0
    Last Post: 21st April 2009, 17:28
  2. Position in a QPixMap created from a QGraphicsScene
    By stevel in forum Qt Programming
    Replies: 8
    Last Post: 8th April 2009, 22:39
  3. Creating new scene from a part of an old one
    By maverick_pol in forum Qt Programming
    Replies: 6
    Last Post: 28th November 2007, 18:14
  4. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 17:51
  5. QPixmap and HBITMAP
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2006, 16:24

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
  •  
Qt is a trademark of The Qt Company.