Qt World Summit: Register Today!

Qt Gestures and Signals.

  • I was wondering how do you recognize gestures in Qt, and how to link actions to those gestures. I was thinking of making a signal that when the gesture(swipe) is made, it will trigger a slot(run a program). But I don't know how to make a signal(slot is made), and how to implement the gesture recognition in the code.

    Edit: this is for Symbian^3 OS version Belle.

  • Are you using QML or plain C++ to implement your application UI? If you're using C++, you could inspect touch events directly, to perform gesture recognition. If you're using QML, you can use a MouseArea element, and use mouse.x and mouse.y data inside an onPressed handler.

    As to how you recognise gestures, once you have access to the touch data, well, that's a rather more complex question.

    Good luck!

  • Did you have a look at the documentation for QGesture & friends ?

  • Grab the gesture type. Handle it in your QWidget::event(). Emit the proper signal. See the Gesture Programming & Signals + Slots documentation. And better do the last one first. ;)

  • Hey guys, to chriadam, I am using C++.
    to morinehtar0 I tried to understand it but I still am a rookie. I know Java and Actionscript. But C++ is a bit different.
    THANKS GUYS!!! just think I have Finished it!!!

    void MainWindow:: initialY(){
    void MainWindow::finalY(){
    void MainWindow::action(){
    //put function here.

    int MainWindow::MouseLocator()
    QPoint relativeMousePos = QCursor::pos();
    int a=relativeMousePos.y();
    return a;
    Here is my code. initialY() runs when I press the button. finalY() runs when I release the button. also action() runs when I release my button. MouseLocator() just takes the mouse location at that instant. MY FIRST PROGRAM IN C++ And I have sort of imitated the Swipe gesture. Thanks guys!

    Edit: also the init and fin variables were global int variables. just to take in the Y value.

    Edit: please use @ tags around code snippets; Andre

  • @nonikhanna
    Please use tag @ for code snippets, thank's

Log in to reply