Results 1 to 4 of 4

Thread: adding QPixmap to scene

  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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: adding QPixmap to scene

    You have tried those methods and...?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    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 Re: adding QPixmap to scene

    Quote Originally Posted by wysota View Post
    You have tried those methods and...?
    ...and the graphic does not get added to the scene. its a calendar app that shows information from a data base added by scene->addText("bla bla") , i see all text info that is added but i cant seem to get the pixmap to be added to the scene. i am sure it is something simple but i havent figured it out.

  4. #4
    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: adding QPixmap to scene

    Where are you getting the pixmap from ? Make sure it is set properly in mime data.

    Secondly what format is the pixmap ? (png,jpg, etc) may be ur Qt was not compiled for them. Also check if you can display that pixmap on a simple QLabel instead of scene

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.