I'm doing a game in which the QGraphicsItem character is moved by the left/right keys and then, the scene is scrolled inside the view. But I also want to put a top frame with game points, timers and so on. The top frame is of type QHBoxLayout. What I have so far is:
myCharacter = new character();
scene->addItem(myCharacter);
topFrame = new topframe();
topFrame->setGeometry(0,0,100, 30);
scene->addWidget(topFrame);
// then I try to update top frame every frame
topFrame->setGeometry(view->pos().x(),0,100,30);
QGraphicsScene scene;
myCharacter = new character();
scene->addItem(myCharacter);
topFrame = new topframe();
topFrame->setGeometry(0,0,100, 30);
scene->addWidget(topFrame);
QGraphicsView view = new QGraphicsView(scene);
// then I try to update top frame every frame
topFrame->setGeometry(view->pos().x(),0,100,30);
To copy to clipboard, switch view to plain text mode
the good news is this actually works and moves the top frame when left/right keys are pressed, but the character is moving way much faster than the top frame which falls behind and slowly gets outside of the view. Is it possible to do the top frame in some other way to have it fixed as an additional layer of the view or something like that?
Bookmarks