QGraphicsView から現在シーンにあるウィジェットにすべてのキー押下イベントを転送しようとしています。
私の QGraphicsView は次のようになります。
Character_controller::Character_controller(Game_state * game_state) : Game_base_controller(game_state) {
this->character = new Character(this->game_state);
this->scene->addWidget(this->character);
connect(this, SIGNAL(keyPress(QKeyEvent *)), this->character, SLOT(update()));
}
そして、QWidget をサブクラス化する私のキャラクターは、すべてのキープレス イベントを受け取る必要があります。
Character::Character(Game_state * game_state) : Base_object(game_state) {
}
Character::~Character() {
}
void Character::update() {
cout << "HELLO FROM TIMER CONNECTED ITEM" << endl;
}
何らかの理由で、これは機能しません。すべてのキープレス イベントをビューから自分のキャラクターに転送するにはどうすればよいですか?
私が得るエラーはこれです:
Object::connect: No such signal game::Character_controller::keyPress(QKeyEvent *) in implementation/game_controllers/character_controller.cpp:21