I'm having trouble connecting a signal in a QPushButton
to a slot in my QGraphicsView
.
My Push Button Header:
class Button : public QPushButton {
Q_OBJECT
public://public constructors / destructors
Button(Game_state * game_state, QWidget *parent = 0);
~Button();
protected://signals / slots etc QT
void mousePressEvent(QMouseEvent * event);//
signals:
void updated() { std::cout << "HELLO FROM THE UPDATED METHOD" << std::endl;}
protected:
Game_state * game_state;//this is the global gamestate method
char * action_name;//this is the application name that is responsible for setting the game_state so the game controller knows what to delete / update
};
You need the Q_Object
macro to compile this with slots, but when I compile I keep getting a vtable reference not found like follows:
Undefined symbols for architecture x86_64:
"vtable for Button", referenced from:
Button::~Button()in buttons.o
Button::~Button()in buttons.o
Button::~Button()in buttons.o
Button::Button(Game_state*, QWidget*)in buttons.o
Button::Button(Game_state*, QWidget*)in buttons.o
When I take out the macro, I can compile it fine, but I keep getting this error when I run:
Object::connect: No such signal QPushButton::updated() in implementation/game_controller.cpp:11
My game_controller
extends QGRaphicsView
and here is my code where I am attempting to connect the Button:
this->button = new Button(game_state);
this->proxy = new QGraphicsProxyWidget();
this->proxy = this->scene->addWidget(this->button);
connect(this->button, SIGNAL(updated()), this, SLOT(update()));
Any help would be greatly appreciated