I have a class inherits QGraphicsRectItem with type function
Qt Code:
  1. int RectItem::type() const
  2. {
  3. return UserType + 1;
  4. }
To copy to clipboard, switch view to plain text mode 
But when I try to coverting a QGraphicsItem pointer to RectItem pointer, the qgraphicsitem_cast returns null.
Qt Code:
  1. QList<QGraphicsItem *> items = scene()->selectedItems();
  2. for(int i=0; i<items.size(); i++){
  3. if(items[i]->type() == UserType + 1)
  4. RectItem*rectItem = qgraphicsitem_cast<RectItem*>(items[i]);
To copy to clipboard, switch view to plain text mode 
Here rectItem is null. However if I change the cast to dynamic_cast, the convertion will be successful.
Qt Code:
  1. QList<QGraphicsItem *> items = scene()->selectedItems();
  2. for(int i=0; i<items.size(); i++){
  3. if(items[i]->type() == UserType + 1){
  4. RectItem*rectItem = dynamic_cast<RectItem*>(items[i]);
To copy to clipboard, switch view to plain text mode 
Here rectItem is the real RectItem selected.

Anyone knows why qgraphicsitem_cast is not working?
Thanks in advance.