Results 1 to 4 of 4

Thread: Activate QPushButton with QCursor

  1. #1
    Join Date
    Sep 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Activate QPushButton with QCursor

    Hello everyone,

    I would like to get some advice. I'm going to subclass QPushButton which will be controlled by a QCursor.
    I want to use QCursor::setPos() to set the position of the cursor which will be responsible for activating a QPushButton.

    The idea is to activate the button after hovering it for longer than 3-5 seconds. I want to use QCursor to control a cursor's position,
    where x and y coordinates will come from a different widget and will be used to activate different buttons. The only way I can think
    of is to create a button - animated widget something like a progress bar which after filling itself completely will be activated.

    The concept will be very similar to the one used in MS Kinect games, where the buttons are activated using hands.

    Any ideas and suggestions are more than welcome, maybe I'm missing something that could help me to implement
    this kind of functionality. The biggest issue will be most probably with controlling a cursor's position within my window.

    Thank you,
    Chris

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Activate QPushButton with QCursor

    Since I don't know MS Knect games, its hard for me to follow on what you exactly are trying to achieve.
    However:
    The idea is to activate the button after hovering it for longer than 3-5 seconds.
    For this you don't need a QCursor - you can just trap the buttons enter and leave events.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Sep 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Activate QPushButton with QCursor

    Thanks for the reply. I think I didn't have a clear idea what I want to do at the time when I posted the question for the first time. Today I'll try to keep it simple.

    I've got separate widget - QGLWidget. The GL window will be displayed on the separate screen.
    On top of my GL widget or within that widget I will add something like a pushbutton or some simple graphics. I'm only interested in the position of that region within GL widget.

    Then I want to use 2d position of my hand from the camera image to control the previously mentioned region. The way I want to do that is to call a desired function after 2d point will be within region of interest for longer than 3 seconds let say.

    I've seen something similar where MS Kinect and Qt gestures were used.

    I'm not sure if this makes more sense, but it is doable.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Activate QPushButton with QCursor

    I think Daniel's answer still stands -- the button doesn't care about Kinect or anything else related to how the cursor position is set. You get enter and leave events for the button and in the enter event you can start a timer. If it fires before a corresponding leave event is received then it means the cursor was over the button for the specified amount of time and you can call click() on the button.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Comparing QCursor::pos() to QGraphicsItem::pos()
    By mongooseblarg in forum Qt Programming
    Replies: 1
    Last Post: 8th March 2012, 13:30
  2. Replies: 1
    Last Post: 11th April 2009, 22:27
  3. QCursor
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 11th October 2007, 19:57
  4. Why QCursor setPos() dosen't work here?
    By kar98k in forum Qt Programming
    Replies: 8
    Last Post: 1st June 2007, 12:52
  5. QCursor::setPos
    By Levon Nikoghosyan in forum Qt Programming
    Replies: 1
    Last Post: 26th December 2006, 08:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.