Results 1 to 5 of 5

Thread: QGraphicsItem Subclassing

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default QGraphicsItem Subclassing

    Hi,
    This may be a basic C++ question, not sure.
    I have a QGraphicsRectItem class, call it CIRCLE which implements painting, item events and such.
    Now I want to make another QGraphicsItem called SQUARE. In this item SQUARE, it contains many CIRCLE items.
    The SQUARE class only needs to create the circle items. I want the scene to add the SQUARE item, instead of creating many circle items in my scene view. ( just trying to clean up the code)
    I get this error when compiling
    :294: error: cannot declare variable 'SQUARE' to be of abstract type 'SQUARE'
    :84: note: because the following virtual functions are pure within 'SQUARE'

    /usr/local/Trolltech/QtEmbedded-4.4.1-arm/include/QtGui/qgraphicsitem.h:224: note: virtual QRectF QGraphicsItem::boundingRect() const
    /usr/local/Trolltech/QtEmbedded-4.4.1-arm/include/QtGui/qgraphicsitem.h:243: note: virtual void QGraphicsItem:aint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)

    If I implement these functions in the SQUARE class then there is no error. However, I do not need to paint events for SQUARE. The painting is handled by CIRCLE class.
    Please help.

    Thank you
    Last edited by QbelcorT; 18th November 2008 at 08:12.

Similar Threads

  1. QGraphicsItem doesn't inherit QObject?
    By xyzt in forum Qt Programming
    Replies: 6
    Last Post: 26th September 2011, 14:59
  2. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31
  3. QGraphicsItem force boundingRect
    By bunjee in forum Qt Programming
    Replies: 0
    Last Post: 27th September 2008, 16:49
  4. Problem with rotation of QGraphicsItem
    By ashishsaryar in forum Qt Programming
    Replies: 2
    Last Post: 10th July 2008, 15:03
  5. Snap-to grid on QGraphicsItem
    By hardgeus in forum Qt Programming
    Replies: 9
    Last Post: 28th April 2008, 16:22

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.