I got a superclass named Obje
#ifndef OBJE_H
#define OBJE_H
#include <QString>
class Obje
{
public:
Obje();
QString name="";
int id;
int itemid=0;
void setItemid(int i);
virtual void update(){};
};
#endif // OBJE_H
and I got a subclass named Npc
#ifndef NPC_H
#define NPC_H
#include "obje.h"
#include "QString"
#include "QPixmap"
class Npc : public Obje
{
public:
Npc(QString dir="left");
QString direction="left";
QPixmap* spriteSheet = nullptr;
QPixmap face;
QPixmap sprites[3];
void update(int nid);
QPixmap* getCurrentSprite();
int currentFrame;
QString frameDirection;
};
#endif // NPC_H
I also got a class to manage listWidgets
class ListUpdate
{
public:
ListUpdate();
static void update(QListWidget *q, vector<Obje>& i);
private:
static struct item{
QString id;
QString name;
QPixmap px;
};
static QListWidgetItem* newItem(ListUpdate::item &i, int c);
};
#endif // LISTUPDATE_H
When I try to pass object named "npcs" which is type vector"Npc" to ListUpdate::update , it gives this error Passing the vector:
ListUpdate::update(ui->listWidget,npcs);
error:
C:\Qt Projects\RpgEditor\npcscreen.cpp:64: error: C2665: 'ListUpdate::update': none of the 3 overloads could convert all the argument types
Note: I also got 2 other overload functions and I didn't write them here to prevent unnecessary confusion(that's why it says , "none of the 3 overloads")
Why doesn't it accept my subclass ?