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. Colliding Mice Qt 4 example question
Forum Updated to NodeBB v4.3 + New Features

Colliding Mice Qt 4 example question

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.0k 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.
  • S Offline
    S Offline
    sbono
    wrote on last edited by
    #1

    There is a function in mouse.cpp

    @void Mouse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
    @

    I didn't see it being called anywhere so decided to step in main(). The last line in main() is
    @return app.exec();@

    when this line is executed, the code steps into the paint function. Who is sending in the arguments like QPainter* etc?

    Also, this function declaration from mouse.cpp has these mysterious pointers without any name, e.g. QStyleOptionGraphicsItem *. I haven't seen that before. What does it mean to just have a pointer and no name?
    thanks,
    sb

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      The method is executed when the widget/item is shown.

      The method is virtual, so the signature must be retained. If you do not need an argument, you can omit a name for it. If you have a name, the compiler will generate a warning (unless you use Q_UNUSED).

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on last edited by
        #3

        That's a QGraphicsItem, right? The QGraphicsView framework will invoke the paint method every time it is necessary to draw your item, so you don't have to care about that, and will pass to it an initialized QPainter to draw.

        [quote]Also, this function declaration from mouse.cpp has these mysterious pointers without any name, e.g. QStyleOptionGraphicsItem *. I haven’t seen that before. What does it mean to just have a pointer and no name?[/quote]

        It simply means that you are not going to use those parameters.

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

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

          Thank you both so much for the information!
          sb

          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