QTimer with QDragEvent problems - c++

I have a GUI application where you can drag widgets around in a QGraphicsView/Scene. You can also pan and zoom while you're not dragging a widget.
What I want:
I want to make it so that when you're dragging an item near the edge of the screen that it starts to pan in that direction and keeps panning even if the mouse isn't moving, but the mouse still needs to be in the top/left/right or bottom 10% of the screen.
What I've tried:
Inside the dragMoveEvent I check if the mouse is on the edge of the screen. If so I start a Qtimer with 15msec timeout. On timeout a function is slotted to pan the scene in the right direction by updating the center. This approach WORKS, BUT when i leave the mouse still on the edge the panning is choppy and if the mouse is moving around inside the edge then the panning is smooth as it should be.
Bottom Line:
Why is the panning only choppy/laggy when the mouse isn't moving? How do I fix it so that the panning is smooth like when you move the mouse around inside the edges?

What happens when you increase/decrease your timeout?

Related

Is there an SFML delta mouse movement event?

I'm trying to implement a way to click and drag the screen in SFML. The idea being that when the user clicks down on their mouse, an sf::View gets changed by how much the user moves their mouse until they release it.
I tried to use the sf::Event::MouseMoveEvent struct under the assumption it would give the mouse movement and not the position. When I used it in code, however, it gets the position.
I could try and keep track of the previous mouse position and subtract it out to get the change, but I would expect that there would be a struct or function that would give me the delta position. It has this functionality for the scroll wheel, so I'd hope it does for the mouse.

Qt mouseMoveEvent - tracking mouse position

I'm programming my first 2D game in Qt.
I have QWidged where I draw my game (isometric view). When mouse enters border of widget it moves map view (like in every strategy game...).
And here is my trouble... I'm tracking mouse position with mouseMoveEvent but it fires only when mouse moves (only when position changes). So map moves only when I move mouse at borders. If mouse stand still, map does not move (mouseMoveEvent is not triggered). And I have no idea how to solve this. It's annoying when you try to play it.
This is my first post here.. and I hope that I explained my problem clearly :)
Edit (little more clarify):
Imagine this: you want to move map. So you move mouse to the edge of screen (QWidget) but at the moment when you stop mouse, map stops moving too. But mouse is still at edge of screen. What I want to do is that map will still move after mouse stops at edge.
You can create QPropertyAnimation for coordinates and start/stop it when mouse moves to/from widget's border.
Or you can remember current state ("changing x by -1 every 100ms, changing y by 0") and call some slot that does the real moving with QTimer.

ccmenuitem click response position is off after changing cccamera coordinates

I'm developing an ios game with cocos2d currently. There is a ccmenuitem on the screen. As the game starts, the player moves forward. In order to keep the player on the centre of the screen, the cccamera coordinates are changing according to player's position. The problem is when I click on the menuitem after the camera coordinates are changed, it does not response. For example, if the camera coordinates are moved 10 px to the right, I have to click 10px to the right of the the menuitem in order to "click on it".
Does any one know how fix this ? :(
This is a know side-effect of using CCCamera. There's rarely any need for using the camera though because you can achieve the same scrolling effect by simply moving the layer in the opposite direction.

Mouse programming

https://stackoverflow.com/questions/9466359/graphics-editor-in-c
I've developed a simple graphics editor in c++.It requires me to drag the mouse to draw a shape .After drawing the shape I want to fill it by picking a color but since dragging the mouse amounts to a large number of clicks because of which the entire screen gets filled with a default color even before i've drawn the shape. delay() doesn't work either.
the mouse click event in turbo c++ has two part. one where you press the button and two when you release the button. you need to drag so you should use the clrscr() function in the loop which goes on iterating until the mouse button is pressed down along with the code for the shape you want to draw. that way your screen keeps getting updated when you are dragging the mouse. and the loop ends when you release the button.
for filling the shape using the flood fill function should suffice
Perhaps one of the following links is what you're looking for:
http://www.codeproject.com/Articles/11313/Mouse-Programming-in-C-C
http://www.cprogrammingreference.com/Tutorials/Advance_Tutorials/mouseprogramming.php
http://www.brackeen.com/vga/mouse.html

Finding current mouse position in QT

This is my first attempt at writing a QT app, and I'm just trying to get a feel for how it works. My goal is to have a 400x400 widget which knows the exact position of the mouse when the mouse is hovering over it. For example, if the mouse was hovering in the top left corner, the position might be 10,10 (or something similar). If the mouse is in the bottom right corner, it might say 390,390.
Eventually, these coordinates will be displayed in a label on the main window, but that should be trivial. I'm stuck at the actual fetching of the coordinates. Any ideas?
For your widget, you must enable mouse tracking.
Then, you can either install an event filter, paying attention to mouse events and looking for the move event, or you can inherit from QWidget and override the mouse event, looking for mouse move events.
http://doc.qt.io/qt-4.8/qwidget.html#mouseTracking-prop
http://doc.qt.io/qt-4.8/eventsandfilters.html
http://doc.qt.io/qt-4.8/qmouseevent.html
If you are ever in a situation when you don't need actual tracking, just position at the moment, you can use QCursor::pos().