×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    3

    Problem with touch : How to get touch to work with my application

    Hi

    I am trying to implement an application that takes touch alone and ignores mouse events. From the developer doc , I understand that Qt::WA_AcceptTouchEvents has to be enabled for the widget and the event() fn needs to be reimplemented. I have a following code segment to do this. Am i missing something. I am not able to get the touch to work.
    ---------------------------------------------------------
    touch3.h

    class Touch3 : public QWidget
    {
    Q_OBJECT

    public:
    Touch3(QWidget *parent = 0);
    ~Touch3();
    bool event(QEvent *);

    public slots:
    void appendText1();
    void appendText2();
    private:
    QTextEdit *displayArea;
    QPushButton *helloButton;
    QPushButton *worldButton;

    QGridLayout *mainLayout;

    }
    =================================================

    main.cpp

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    Touch3 w;
    w.show();
    return a.exec();
    }


    ==================================================

    touch3.cpp

    Touch3::Touch3(QWidget *parent)
    : QWidget(parent)
    {

    setAttribute(Qt::WA_AcceptTouchEvents);

    displayArea = new QTextEdit;
    helloButton = new QPushButton;
    helloButton->setText(tr("Hello"));
    worldButton = new QPushButton;
    worldButton->setText(tr("World"));

    mainLayout = new QGridLayout;
    mainLayout->addWidget(helloButton, 0, 0);
    mainLayout->addWidget(worldButton, 0, 1);
    mainLayout->addWidget(displayArea, 1, 0, 1, -1);

    setLayout(mainLayout);
    setWindowTitle(tr("Hello Touch"));

    }


    bool Touch3::event(QEvent *e)
    {

    switch(e->type())
    {
    case QEvent::TouchBegin:
    case QEvent::TouchUpdate:
    case QEvent::TouchEnd:
    displayArea->append(tr("Touch active"));
    break;
    case QEvent::MouseButtonPress:
    case QEvent::MouseButtonDblClick:
    case QEvent::MouseButtonRelease:
    case QEvent::MouseMove:
    case QEvent::MouseTrackingChange:
    e->ignore();
    default:
    return QWidget::event(e);
    }
    return true;
    }

    ===================================


    Please help in to understand how to get touch working in my application.

    Thanks a lot in advance,
    Bala

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Problem with touch : How to get touch to work with my application

    Touch events are not so general thing and heavily depends on hardware platform. What is yours?

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    3

    Re: Problem with touch : How to get touch to work with my application

    I am presently using Nokia SDK simulator to simulate the touch device.

    The hardware spec is not yet avbl as a few boards are currently being evaluated.

    I understand that touch behaviour can be device dependent and it will be taken into consideration when deciding on the board. However, do we need to take into consideration the hardware dependencies, if using the Qt simulator for GCC on a Ubuntu x86 PC and developing an application that is touch aware.

    Please advise.

    Thanks a lot,
    Bala

  4. #4
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Problem with touch : How to get touch to work with my application

    Quote Originally Posted by balasaravanan View Post
    I am presently using Nokia SDK simulator to simulate the touch device.
    If this means Qt Simulator, it's just desktop SDK, which doesn't support touch events.

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    3

    Re: Problem with touch : How to get touch to work with my application

    Hi divanov


    Thanks a lot for the clarification.


    I would like to know if there is any way to simulate the touch behaviour in desktop SDK. I would like to have a head start in developing the touch app before the board arrives. But i will be in a fix if am not able to see the touch simulated on the desktop.

    Any advice in this issue will be greatly helpful.

    Thanks and regards,
    Bala


    Quote Originally Posted by divanov View Post
    If this means Qt Simulator, it's just desktop SDK, which doesn't support touch events.

  6. #6
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Problem with touch : How to get touch to work with my application

    Probably you can alter Qt source codes
    http://qt.gitorious.org/qt/qt/trees/4.7

Similar Threads

  1. Replies: 8
    Last Post: 2010-03-25, 14:51
  2. problem with appswitch - dosent work ?
    By adamski9000 in forum Symbian
    Replies: 1
    Last Post: 2010-03-03, 18:51
  3. Replies: 5
    Last Post: 2010-01-28, 15:01
  4. Problem MMC+USB Connection
    By Fede81 in forum Symbian
    Replies: 1
    Last Post: 2007-06-14, 06:13
  5. Problem MMC+USB Connection
    By Fede81 in forum General Development Questions
    Replies: 3
    Last Post: 2006-07-19, 15:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×