[Solved] Animation of cursor on touch



  • Hi

    I have Qt 4.6.3 on eLinux and I am using a PCAP touch that works in parallel to the mouse also using events (Touch Handlers=mouse1 js0 event1 evbug, Mouse Handlers=mouse0 event0 evbug).

    I now need to have some animation like a "ring" or something that shows up when a touch event has occurred. I mean, not on a simple touch but on the release that launches the touch function like the button click (event type sequence: 2 5 3).

    Is there something alike "ready to use" in Qt or how would I have to implement something like this?

    Thanks
    McL


  • Lifetime Qt Champion

    Hi,

    Do you mean change the mouse cursor and show a spinning wheel ?



  • Yup, kind of. Showing a spinning wheel for a second or so as a visual feedback to the user that he just clicked an element.



  • To start off I tried to change the cursor, though it's only B/W and not animated.

    QPixmap TouchEventCursorPixmap(":/TouchEventPNG32");
    QCursor TouchEventCursor(TouchEventCursorPixmap, -1, -1);
    QApplication::setOverrideCursor(TouchEventCursor); 
    

    If I am correct that should change my cursor until I call it off with restoreOverrideCursor().
    However, nothing happens and no error on console is output.

    What am I doing wrong?


  • Lifetime Qt Champion

    Did you check that the pixmap is valid ?



  • Thanks for answering. Yes, it is. While playing around I had a too large pixmap. It then did throw an error on the console.
    Just found: To make it run I had to place a
    QApplication::processEvents();
    after the setOverrideCursor. This is probably only needed because I placed it in the MainWindow constructor for testing purpose. I will move it to the notify reimplementation where I catch the mouse and keyboard events and then would probably not need it.

    Is there a way to have at least a gray scaled or even colored cursor, maybe bigger than the current maximum of 64x64?

    If not, I'll probably have to implement a workaround like showing a graphic for a short time at the location of the touch/click event.
    Would that support an animated gif, with transparency?
    Do you have a better suggestion?



  • Got stuck :-|
    I seem not to be able to call a function in my class
    class QTGUI_MainWindow : public QMainWindow
    from the reimplementation of the notify event:

    class MyApplication : public QApplication
    {
      public:
        MyApplication(int &argc, char **argv ) : QApplication(argc, argv)
        {
        }
        virtual bool notify ( QObject *receiver, QEvent *event )
           switch( event->type() )
          {
    ....
    

    There's something I just don't get with these classes in C++ - still used to years of ANSI C.
    Can somebody give me a hint how I can solve this?
    Tanks a lot.


  • Lifetime Qt Champion

    Do you mean your notify implementation doesn't get called ?



  • Nope, it's called and working perfectly.
    I can perfectly manipulate the cursor with these lines from the notifier:

    QPixmap TouchEventCursorPixmap(":/Ring3");
    QCursor TouchEventCursor(TouchEventCursorPixmap, -1, -1);
    QApplication::setOverrideCursor(QCursor(TouchEventCursor));
    

    Because the problem I got stuck with is actually something different than the main topic of this thread I opened a new one for this here

    What is remaining open in this thread is the following:
    Is there a way to have at least a gray scaled or even colored cursor, maybe bigger than the current maximum of 64x64?
    If not, I'll probably have to implement a workaround like showing a graphic for a short time at the location of the touch/click event.
    Would that support an animated gif, with transparency?
    Do you have a better suggestion?


  • Lifetime Qt Champion

    I don't think it is, however if you need that big a feedback, you should maybe avoid trying to do it on the cursor and have something more general like a spinner in a corner



  • Couldn't find anything either.
    For now, I leave it with the cursor solution. And I'll try to let a graphic pop up at the cursor location instead of changing the cursor as an option.

    Thanks anyway.



  • Need to dig up this old thread ...

    I (customer) would like to have graphic shown instead of the simple over-ridden cursor.
    I am thinking of a png with transparency or even of an animated gif.

    What is the best approach to have a small graphic shown very quickly (load fast)?

    Something like this maybe:

    QGraphicsScene scene;
    QGraphicsView view(&scene);
    QGraphicsPixmapItem item(QPixmap("c:\\test.png"));
    scene.addItem(&item);
    view.show();
    

    I'd load the graphic at boot and later only show and hide at the relevant position.
    Or is there a faster or better way?


  • Lifetime Qt Champion

    At a fixed position ?



  • Nope, varying with current touch position.
    Couldn't get to display that graphic, and not frameless with the Scene. Tried with a QLabel instead .. again to no avail.

    Ended up in adding a Label in the Designer and set it transparent in Designer and load the png in Designer. From code, I am now only updating the position and show and hide.
    This now works as expected for a static image. I wonder if this also works with an animated GIF ... will see.

    Thanks anyway


  • Lifetime Qt Champion

    IIRC, you can use QMovie for gifs



  • I'll try that.
    Thanks



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.