の信号QPushButton
を のスロットに接続できませんQGraphicsView
。
私のプッシュボタンヘッダー:
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
};
これをスロットでコンパイルするにはマクロが必要ですが、Q_Object
コンパイルすると、次のように vtable 参照が見つかりません。
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
マクロを取り出すと、問題なくコンパイルできますが、実行すると次のエラーが発生し続けます。
Object::connect: No such signal QPushButton::updated() in implementation/game_controller.cpp:11
私のgame_controller
拡張QGRaphicsView
とここにボタンを接続しようとしている私のコードがあります:
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()));
どんな助けでも大歓迎です