Results 1 to 9 of 9

Thread: Subclassing QGraphicsPixmapItem ???

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2016
    Posts
    23
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Subclassing QGraphicsPixmapItem ???

    I'm trying to establish an array of QGraphicsPixmapItems.

    Qt Code:
    1. // Pre-Try as a general check:
    2.  
    3. QPixmap pixmapA = QPixmap( ":/images/imageA.png" );
    4. QGraphicsPixmapItem pixmapItemA;
    5. pixmapItemA.setPixmap( pixmapA );
    6.  
    7. // This works
    To copy to clipboard, switch view to plain text mode 

    But then:

    Qt Code:
    1. // First Try
    2.  
    3. QVector< QGraphicsPixmapItem > itemVector( 100 );
    4. itemVector[23].setPixmap( pixmapA );
    5.  
    6. // Fails: In QGraphicsPixmapItem, 'DISABLE COPY' is private
    To copy to clipboard, switch view to plain text mode 

    And:

    Qt Code:
    1. // Second Try:
    2.  
    3. QVector< QGraphicsPixmapItem > itemVector( 100 );
    4. QGraphicsPixmapItem pixmapItemA;
    5. pixmapItemA.setPixmap( pixmapA );
    6. itemVector[23] = pixmapItemA;
    7.  
    8. // Fails: In QGraphicsPixmapItem, 'operator=' is private
    To copy to clipboard, switch view to plain text mode 

    And, finally:

    Qt Code:
    1. // Third Try:
    2.  
    3. QVector< QGraphicsItem > itemVector( 100 );
    4. QGraphicsPixmapItem pixmapItemA;
    5. pixmapItemA.setPixmap( pixmapA );
    6. itemVector[23] = pixmapItemA;
    7.  
    8. // Fails - invalid abstract return type 'QGraphicsItem'
    To copy to clipboard, switch view to plain text mode 

    Is there something I'm missing?

    Or, am I going to have to subclass QGraphicsPixmapItem in order to get this to work?

    If the latter, could somebody please point me to a reasonably straightforward link on subclassing? I've never tried anything like that and have numerous trepidations.

    BTW, I do note in qglobal.h :

    Qt Code:
    1. /*
    2.   Some classes do not permit copies to be made of an object. These
    3.   classes contains a private copy constructor and assignment
    4.   operator to disable copying (the compiler gives an error message).
    5. */
    6. #define Q_DISABLE_COPY(Class) \
    7. Class(const Class &) Q_DECL_EQ_DELETE;\
    8. Class &operator=(const Class &) Q_DECL_EQ_DELETE;
    To copy to clipboard, switch view to plain text mode 

    Why would copies not be permitted? If there's a valid reason, subclassing to get past it might break something, in which case Qt would seem not to be what I need to use ???
    Last edited by mdavidjohnson; 1st November 2016 at 23:45.

Similar Threads

  1. problem with QGraphicsPixmapItem
    By JustJ in forum Newbie
    Replies: 2
    Last Post: 4th November 2014, 09:14
  2. QGraphicsPixmapItem
    By erfan in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2012, 21:54
  3. subclassing QGraphicsItem, QGraphicsPixmapItem
    By rogerholmes in forum Newbie
    Replies: 3
    Last Post: 26th August 2009, 23:12
  4. Shape of QGraphicsPixmapItem
    By StefanHirche in forum Newbie
    Replies: 4
    Last Post: 5th September 2007, 15:14
  5. QGraphicsPixmapItem performance
    By cerber in forum Qt Programming
    Replies: 21
    Last Post: 22nd August 2007, 13:41

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.