Hey there.

I have array of custom structure object called Sprite, it looks like this:
Qt Code:
  1. struct Sprite
  2. {
  3. Sprite() { image = new QImage(32, 32, SPRITE_FORMAT); }
  4. void setSprite(QImage *inImage) { image = inImage; }
  5. QImage *getSprite() { return image; }
  6.  
  7. QImage *image;
  8. uint8_t width, height, r, g, b;
  9. };
To copy to clipboard, switch view to plain text mode 

Now, I have QListWidget and I'd like to insert items with icons from that array, but I have problem. QPixmap::fromImage takes &QImage as parameter, and my function (getSprite()) returns pointer.

I have following code (which crashes):
Qt Code:
  1. foreach(Item *x, ItemsLoader->xmlMap)
  2. {
  3.  
  4. QString itemText = x->getName();
  5. itemText = itemText.left(1).toUpper() + itemText.mid(1);
  6. item->setText(itemText + " (ID: " + QString::number(x->getId()) + ")");
  7.  
  8. Sprite *sprite = ItemsLoader->sprMap[x->getId()];
  9. item->setIcon(QIcon(QPixmap::fromImage(*sprite->getSprite())));
  10.  
  11. ui->ItemsListWidget->addItem(item);
  12. }
To copy to clipboard, switch view to plain text mode 

I guess following line is causing application crash:
Qt Code:
  1. item->setIcon(QIcon(QPixmap::fromImage(*sprite->getSprite())));
To copy to clipboard, switch view to plain text mode 

How do I convert correctly from QImage* to &QImage?