Results 1 to 2 of 2

Thread: GraphicsItem_cast question

  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 GraphicsItem_cast question

    I am using the code from the Diagram example ,

    I want to be able to add pictures to the scene, i ALMOST have it working but i can not figure out how to use a QGraphicspixmapItem with this function. It returns error that QGraphicsmap* can not be converted QGraphicsPixmapItem. how can i do this ?

    Qt Code:
    1. foreach (QGraphicsItem *item, scene->selectedItems()) {
    2. if (item->type() == DiagramItem::Type) {
    3. qgraphicsitem_cast<DiagramItem *>(item);
    4. }
    5.  
    6. int x= item->boundingRect().center().x();
    7. int y= item->boundingRect().center().y();
    8. if(ui->rotateButton->isChecked())
    9. {item->setTransform(QTransform().translate(x, y).rotate(-value).translate(-x, -y));db->updateAngle(-value);}
    10. else
    11. {item->setTransform(QTransform().translate(x, y).rotate(value).translate(-x, -y));db->updateAngle(value);}
    12. }
    To copy to clipboard, switch view to plain text mode 

  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: GraphicsItem_cast question

    What is QGraphicsmap and what is DiagramItem? How is the code you pasted related to the problem? You do realize the whole if block is a no-op, right?
    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.


Similar Threads

  1. licensing question
    By tommy in forum Installation and Deployment
    Replies: 4
    Last Post: 14th April 2010, 11:54
  2. Replies: 0
    Last Post: 31st May 2009, 16:51
  3. Access to QSqlTableModel::isDirty Question.
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 12th April 2007, 17:49
  4. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34

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.