How to call drawBackground function after timeout of QTimer [SOLVED]
-
My problem is, when I create the timer and assign it to the slot drawBackground, which I have created, I get this out on the console
"QObject::connect: Incompatible sender/receiver arguments
QTimer::timeout() --> Game::drawBackground(QPainter*,QRectF)"
Is there any way to circumvent the issue? I need to be able to call it every so often so that when the user hits play, the background of the game gets drawn, instead of having the main menu background as the game background. Here is the code, in case you want to look. Also open to other alternatives. Thank you in advance -
hi
The timeout signal must be linked to a slot that has same signature.
timout signal has no arguments so the slot cannot have either.
so
make a slot in game called updatebackground()
link timeout to updatebackgroundin updatebackground
call drawBackground
or update() if the paint already can draw the background. -
hi
The timeout signal must be linked to a slot that has same signature.
timout signal has no arguments so the slot cannot have either.
so
make a slot in game called updatebackground()
link timeout to updatebackgroundin updatebackground
call drawBackground
or update() if the paint already can draw the background.@mrjj How do I link updateBackground to drawBackground? I am slightly confused, but thanks for the quick answer
-
Hi,
Since you are using a QGraphicsScene why not use a QGraphicsPixmapItem that you set with your background image ?
-
Hi,
Since you are using a QGraphicsScene why not use a QGraphicsPixmapItem that you set with your background image ?
@SGaist Sometimes the simplest answer is the best. Thank you for the idea, can't believe I didn't think about it. It works perfectly!
-
You're welcome !
An outside look from time to time can give some good ideas :)