×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    18

    Unhappy TouchInput in a QWidget

    i am trying to build a painter using Qt so i can run it on my nokia 5800 ... However, i can't find a way to use the touch input with the widget!

    all i want to do is this:
    tap a "pixel"
    get x,y coordinates
    drawLine 0,0 to x,y

    I cant get the touch input, and it is honestly depressing me! i tried QMouseEvent, but it always returned 11,11 , which i suppose are the x and y of the widget's upper left corner!

    i am really late on my project, any help would be appreciated

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: TouchInput in a QWidget

    Which mouse event are you intercepting -- mousePressEvent, mouseReleaseEvent, or mouseMoveEvent?

    Are you using event ->pos() to get the position?

  3. #3
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: TouchInput in a QWidget

    To be added to the previous comment, this example is worth to be checked
    http://qt.gitorious.org/qt/qt/trees/...dgets/scribble

  4. #4
    Registered User
    Join Date
    Mar 2010
    Posts
    18

    Re: TouchInput in a QWidget

    Quote Originally Posted by danhicksbyron View Post
    Which mouse event are you intercepting -- mousePressEvent, mouseReleaseEvent, or mouseMoveEvent?

    Are you using event ->pos() to get the position?
    void CircularText::mousePressEvent(QMouseEvent *)
    {
    ax=pos().x();
    ay=pos().y();
    }


    this wont work for some reason
    void CircularText::mousePressEvent(QMouseEvent *event)
    {
    ax=event->pos().x();
    ay=event->pos().y();
    }

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2009
    Posts
    430

    Re: TouchInput in a QWidget

    second one should work fine. First attempt is doomed to fail due to QWidget:os() returns position of widget inside container.

  6. #6
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: TouchInput in a QWidget

    There is also QCursor:: pos () static method.
    http://doc.trolltech.com/4.6/qcursor.html#pos

  7. #7
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: TouchInput in a QWidget

    Yeah, pos() without qualification returns this->pos() -- the position of the widget. event ->pos() should work -- what do you mean when you say it "won't work"? What symptom do you get?

  8. #8
    Registered User
    Join Date
    Mar 2010
    Posts
    18

    Re: TouchInput in a QWidget

    Quote Originally Posted by danhicksbyron View Post
    Yeah, pos() without qualification returns this->pos() -- the position of the widget. event ->pos() should work -- what do you mean when you say it "won't work"? What symptom do you get?
    you man are awesome, thanks, it works very well now

    thanks for the help everyone i really appreciate it

  9. #9
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: TouchInput in a QWidget

    Debugging is often a matter of asking the right questions.

Similar Threads

  1. QWidget in QListWidgetItem off-center
    By danhicksbyron in forum Qt
    Replies: 4
    Last Post: 2010-03-18, 16:24
  2. isswue when any QWidget is inserted in a QGridLayout
    By learning_sathya in forum [Archived] Qt SDKs and Tools
    Replies: 1
    Last Post: 2009-11-13, 10:02

Posting Permissions

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