Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Solved] Animation of cursor on touch

[Solved] Animation of cursor on touch

Scheduled Pinned Locked Moved Mobile and Embedded
touchtouchscreenanimationembedded linux
16 Posts 2 Posters 7.1k 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.
  • McLionM Offline
    McLionM Offline
    McLion
    wrote on last edited by
    #4

    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?

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

      Did you check that the pixmap is valid ?

      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
      • McLionM Offline
        McLionM Offline
        McLion
        wrote on last edited by
        #6

        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?

        1 Reply Last reply
        0
        • McLionM Offline
          McLionM Offline
          McLion
          wrote on last edited by
          #7

          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.

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

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

            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
            • McLionM Offline
              McLionM Offline
              McLion
              wrote on last edited by
              #9

              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?

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

                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

                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
                • McLionM Offline
                  McLionM Offline
                  McLion
                  wrote on last edited by
                  #11

                  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.

                  1 Reply Last reply
                  0
                  • McLionM Offline
                    McLionM Offline
                    McLion
                    wrote on last edited by McLion
                    #12

                    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?

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

                      At a fixed position ?

                      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
                      • McLionM Offline
                        McLionM Offline
                        McLion
                        wrote on last edited by
                        #14

                        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

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

                          IIRC, you can use QMovie for gifs

                          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
                          • McLionM Offline
                            McLionM Offline
                            McLion
                            wrote on last edited by
                            #16

                            I'll try that.
                            Thanks

                            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