Undefined reference to vtable error
Any ideas on why this happens?
ahh, add Q_OBJECT to your object ?
class MainWindow : public QMainWindow
then clean and rebuild all.
nanoandrew4 last edited by nanoandrew4
@mrjj Thanks for the quick answer! I don't recall needing that, but when I add it, the whole thing gets worse with it complaining about protected classes and such.
EDIT: In my previous game, it was exactly like that and there was no problem
When adding/removing Q_OBJECT you need to re-run qmake before building, or do a full clean build.
@SGaist I have been trying that several times now, clean all, run qmake and build, but it still outputs the same thing. Thanks for the suggestion tho!
hskoglund last edited by
Hi, you get the vtable error because you're declaring keyPressEvent in your Player class, and that method is from QWidget. So either you also inherit from QWidget or move that method to some other class that also inherits from QWidget...
@hskoglund By inhereting from QWidget I get the same error 3 times. Also, my last project inherited from QGraphicsPixmapItem and had no problem when the code was like this. Any ideas why?
sorry my bad, I read it as QWidget.
Not sure you need Q_OBJECT for QGraphicsRectItem
Deleted the project, ran it on the laptop and everything seems fine now... I will look into it to see what the issue was, maybe there is something missing somewhere