Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. [SOLVED] app.setOverrideCursor() takes too much cpu
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] app.setOverrideCursor() takes too much cpu

Scheduled Pinned Locked Moved Game Development
5 Posts 3 Posters 2.4k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    ritschratsch
    wrote on last edited by
    #1

    Hiho, everybody again :)

    I'm programming a strategy game with the Irrlicht 3D Engine, and use QT for the interface.
    For showing the player if he would select a unit by left click, the cursor changes as soon as it is over a unit.
    It works very well if I just move the cursor over one unit.
    But if I have a bunch of units in a row and move the camera eg. from the left to the right and pass all these units, the camera movement slows down a little bit because the cursor has to change very often.

    I declared the cursors as follows:

    @QCursor * blue = new QCursor((new QPixmap("../media/interface/cursor_blue.gif")));
    QCursor * green = new QCursor(
    (new QPixmap("../media/interface/cursor_green.gif")));
    QCursor * yellow = new QCursor(*(new QPixmap("../media/interface/cursor_yellow.gif")));@

    and change it with:
    @app.setOverrideCursor(*blue);@

    or yellow or green.

    As I can see its only a pointer and the images should already have been loaded so why does the game slows down?
    Is there a better way to acchieve what I want?

    Thanks in advance and best regards

    Ritschratsch

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

      Hi,

      I'm no specialist, but wouldn't it be simpler to also manage your cursor with Irrlicht ?

      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
      • R Offline
        R Offline
        ritschratsch
        wrote on last edited by
        #3

        Hi Sgaist,
        the problem is that I can manage the cursor with Irrlicht only in the Irrlichtwidget. As soon as I move the mouse out of the widget (over the interface), the cursor changes to its normal design. But maybe I could try to manage the cursor with Irrlicht as you said and tell QT to set the cursor to the same image as Irrlicht does, maybe this could work :)

        I'll post as soon as I have time to try it.

        Thanks for your help and have a nice day.

        Ritschratsch

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Skyrpex
          wrote on last edited by
          #4

          I would suggest not using pointers that way. Use QPixmap(...) instead of *(new QPixmap(...)). I don't know why is it slowing do we. Are you sure it isn't your game code?

          1 Reply Last reply
          0
          • R Offline
            R Offline
            ritschratsch
            wrote on last edited by
            #5

            Well I dont think its the game code, because if I move the camera without moving the mouse over the units (or remove the setOverrideCursor function) the game doesn't slow down.
            And yes I got the *(new QPixmap(…)) part from the net and pasted it without really thinking about it.
            But It doesn't matter, I got it :)
            I set the cursor with qt to an image once at gamestart. And change it ingame with irrlicht if I move it over a unit. And if I move the cursor over the interface it doesn't change because I tell qt to use the same image as Irrlicht

            Thanks for your help and good night ;)

            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