c++ - foreach: invalid conversion from 'QGraphicsItem*' to 'QGraphicsItemGroup* -


I am implementing Copy Operation in Graphics for various organizations like point, oval, circle, etc. in Qt, but one Error getting

  error: invalid conversion for 'QGraphicsItemGroup *'  

from 'QGraphicsItem *' to copy operation in cadgraphicsview.cpp The code is:

  zero CadGraphicsScene :: copy () {selectedItems.clear (); Foreign currency (QGraphicsItemGroup * items, item lists) {QString str; If (item-> is selected ()) {if (item-> gt; type () == point :: type) {point * pointItem = (point *) item; Str = QString ("point% 1% 2") .arg (pointItem-> Seixos (.) ()) .arg (pointItem-> Seixos (.) Y ()); }}}}  

in cadgraphicsscene.h

  #ifndef CADGRAPHICSSCENE_H #define CADGRAPHICSSCENE_H #include & lt; QGraphicsScene & gt; # Include & lt; QXmlStreamWriter & gt; # Include & lt; Quodostack & gt; # Include & lt; QLabel & gt; # Include & lt; QFrame & gt; #include "cadcommandadd.h" #include "cadcommandmove.h" Category CadGraphicsScene included: Public QGraphicsScene {Q_OBJECT Public: Clear CadGraphicsScene (QObject * Guardian, QUndoStack *); Enum mode {nodeod, point mode, line mode, circill mode, ellips mode, text mode}; QFont font () const {return myFont; } QColor textColor () const {return myTextColor; } Zero settext (cut cumuler and color); Zero set font (Constant Quanta and Font); Zero altitude (); Zero Write Stream (QXmlStreamWriter * Stream); Zero Read Stream (QXmlStreamReader * Stream); Public slot: zero set mode (mode mode); Zero Selection Items (); Zero Editor LostFocus (Amtext * Item); Zero cut (); Zero per (); Zero paste (); Zero dell (); Protected: Zero Content Content Menu Event (QContextMenuEvent * Event); Zero mousepress event (QGraphicsSceneMouseEvent * mouseEvent); Zero mouseReleaseEvent (QGraphicsSceneMouseEvent * mouseEvent); Zero setflag (); Zero are IseemsSelectable (bool); Zero dragent event (QDragEnterEvent * event); Zero drop event (QDropEvent * event); Zero mouseprint event (QMouseEvent * event); Signal: zero text inserted (QGraphicsTextItem * item); Zero items selected (QGraphicsItem * items); Private: mode unit mode; Quando Stack * Mandostack; Boole MifstClick; Bool mSecondClick; Bool mThirdClick; Boole M Paint Flag; QVector & LT; QPointF & gt; Luggage; QPointF start_p, mid_p, end_p, move_p, check_p; Quepen Pintpen, Linepain; QList & lt; QGraphicsItem * & gt; item list; Point * PointItem; Line * line; Circle * circle item; Oval * alpiethum; MText * textItem; QColor myTextColor; QFont myFont; Typippy QPair & lt; QGraphicsItem *, QPointF & gt; ItemPos; QList & LT; ItemPos & gt; selected items; Private: Quenching * Cut; QECTION * Copy Act; QECTION * Pasteact; }; #endif // CADGRAPHICSSCENE_H  

Help me find it :)

You defined itemList as:

  QList < QGraphicsItem * & gt; item list;  

You are trying to repeat it again:

  foreach (QGraphicsItemGroup * items, itemslists) {// ...}  

You can see this from the document. So each QGraphicsItemGroup is "a QGraphicsItem" but not every QGraphicsItem "A" QGraphicsItemGroup.

If you want to iterate that item, then the item should be a QGraphicsItem, or there must be a QGraphicsItemGroup in the item list. It seems that when you are testing for specific classes, That's what you want


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -