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. Question about "Update" method.

Question about "Update" method.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 825 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.
  • V Offline
    V Offline
    Vect0rZ
    wrote on last edited by
    #1

    Hey folks,

    I'm new around here and I was wonderin something that may sound silly.

    How do I process something that happens onUpdate?

    What do I mean with that is - I'm using SFML for doing some stuff and recently installed QT. If you guys know SFML and worked with it, you know how there is while(window.isOpen()) where you process some stuff that happen realtime.

    Where do we actually process those stuff in QT? Like, for example:

    -Moving an object with mouse (Usually graphics object with flag ItemIsMovable) and then storing the X and Y position of the object on every UPDATE in two variables. Then use those variables eventually.

    Thanks in advance! =]

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      I don't SFML. Let me try to answer based on my understanding..Can you check MouseEvents like mousePressEvent(..) mouseMoveEvent(...) and MouseReleaseEvent(...) and check QMouseEvent class. This is pos(...) method which return the x and y position.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        Hi,

        I presume you are using QGraphicsView?

        while(window.isOpen()) is a polling mechanism.

        Qt uses an event-driven mechanism instead. Whenever the object is moved, Qt automatically calls its mouseMoveEvent().

        You need to subclass QGraphicsItem and reimplement mouseMoveEvent() to perform an action. Then, that action will be performed every time the object is moved.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        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