Results 1 to 3 of 3

Thread: Why QGraphicsItem moveing is valid in half?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Why QGraphicsItem moveing is valid in half?

    Hello everyone
    i subclass QGraphicsItem, in constractor,i add QGraphicsPixmapItem,and a
    QGraphicsTextItem. When drag this item
    Why drag is an effective second half, while the upper part of the void?

    this is my code :

    Qt Code:
    1. YPhoto::YPhoto(QPixmap&pix,QString&info,QGraphicsItem * parent)
    2. :QGraphicsItem(parent)
    3. {
    4. photo=new QGraphicsPixmapItem(this);
    5. photo->setPixmap(pix);
    6. baget=new QGraphicsTextItem(this);
    7. //name=new QGraphicsTextItem(this);
    8. //email=new QGraphicsTextItem(this);
    9.  
    10. QTextDocument* document=new QTextDocument(info);
    11. baget->setDocument(document);
    12. QRect rect=photo->pixmap().rect();
    13. baget->setTextWidth(rect.width());
    14. baget->setPos(this->pos().x(),this->pos().y()+rect.height());
    15.  
    16. }
    17.  
    18. QRectF YPhoto::boundingRect() const
    19. {
    20. QRect rect=photo->pixmap().rect();
    21. QFontMetrics fm(baget->font());
    22.  
    23. rect.setHeight(rect.height()+fm.height());
    24. return QRectF(rect);
    25. }
    26.  
    27. QPainterPath YPhoto::shape() const
    28. {
    29. QRect rect=photo->pixmap().rect();
    30. path.addRect(rect);
    31. path.addPath(baget->shape());
    32. return path;
    33. }
    34.  
    35. void YPhoto::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    36. {
    37. painter->drawPixmap(option->exposedRect,photo->pixmap(),option->exposedRect);
    38. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

Similar Threads

  1. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31

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.