Results 1 to 10 of 10

Thread: Multiple inheritance of QGraphicsView and QGraphicsItem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Join Date
    Apr 2009
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    11

    Default Re: Multiple inheritance of QGraphicsView and QGraphicsItem

    I read the Graphics View Framework docs, updated the coordinates like below, but it didn't make any difference in CPU usage I'm running out of ideas of what else to try

    Qt Code:
    1. LineButton::LineButton(int x, int y)
    2. {
    3. setPos(x, y);
    4. mPixmapBlack = new QPixmap("black.png");
    5. mPixmapYellow = new QPixmap("yellow.png");
    6. mPic = mPixmapBlack;
    7. }
    8.  
    9. QRectF LineButton::boundingRect() const
    10. {
    11. return QRectF(0, 0, LINE_BUTTON_WIDTH, LINE_BUTTON_HEIGHT);
    12. }
    13.  
    14. void LineButton::paint(
    15. QPainter *painter,
    16. const QStyleOptionGraphicsItem *option,
    17. QWidget *)
    18. {
    19. painter->drawPixmap(0, 0, *mPic);
    20. }
    21.  
    22. void LineButton::blink()
    23. {
    24. if (mPic == mPixmapBlack)
    25. mPic = mPixmapYellow;
    26. else
    27. mPic = mPixmapBlack;
    28. QGraphicsItem::update(boundingRect());
    29. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

Similar Threads

  1. QGraphicsView, QGraphicsItem, QGraphicsScene
    By Shuchi Agrawal in forum Newbie
    Replies: 10
    Last Post: 23rd March 2011, 20:50
  2. Replies: 5
    Last Post: 31st December 2010, 11:49
  3. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31
  4. Replies: 2
    Last Post: 12th February 2009, 09:53
  5. (QT4.2-RC1) QGraphicsScene QGraphicsView QGraphicsItem
    By antonio.r.tome in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 10:56

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