Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to call drawBackground function after timeout of QTimer [SOLVED]
QtWS25 Last Chance

How to call drawBackground function after timeout of QTimer [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
qtimerdrawbackgoundcall
6 Posts 3 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nanoandrew4
    wrote on last edited by nanoandrew4
    #1

    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

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 updatebackground

      in updatebackground
      call drawBackground
      or update() if the paint already can draw the background.

      N 1 Reply Last reply
      0
      • mrjjM mrjj

        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 updatebackground

        in updatebackground
        call drawBackground
        or update() if the paint already can draw the background.

        N Offline
        N Offline
        nanoandrew4
        wrote on last edited by
        #3

        @mrjj How do I link updateBackground to drawBackground? I am slightly confused, but thanks for the quick answer

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Since you are using a QGraphicsScene why not use a QGraphicsPixmapItem that you set with your background image ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          N 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Since you are using a QGraphicsScene why not use a QGraphicsPixmapItem that you set with your background image ?

            N Offline
            N Offline
            nanoandrew4
            wrote on last edited by
            #5

            @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!

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You're welcome !

              An outside look from time to time can give some good ideas :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved