Results 1 to 13 of 13

Thread: Disabling Mouse in Qt?

  1. #1
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question Disabling Mouse in Qt?

    Dear Everyone!

    How a way I can disable mouse for a definite period?
    or
    Any way is possible in Qt to disable mouse port (communication port or usb port) logically(programatically)?

    Thanking in advance!
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Disabling Mouse in Qt?

    No, Qt does not provide support for such. Why would you like to do so?
    J-P Nurmi

  3. #3
    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: Disabling Mouse in Qt?

    You can grab the mouse (QWidget::grabMouse()) and ignore all mouse events you receive. Don't forget to release the mouse afterwards or your system becomes unusable.

  4. The following user says thank you to wysota for this useful post:

    bhs-ittech (7th March 2008)

  5. #4
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Disabling Mouse in Qt?

    Quote Originally Posted by wysota View Post
    You can grab the mouse (QWidget::grabMouse()) and ignore all mouse events you receive. Don't forget to release the mouse afterwards or your system becomes unusable.
    I am creating one parent widget & three child QX11EmbedContainer widget.
    In first child widget I am embedding GTK application in QX11EmbedContainer. When I am grabbing mouse, It grabs the mouse only for second & third widgets. but not in First widget.

    This is the reason I want to disable mouse port when I showing the widget & when I close the widget enable the port.

    Is it possible in Qt.
    I am knowing to do this in windows using interrupt handling?
    but How a way it can be implemented in Linux FC6 using pure C/C++ programming if it is not possible in Qt.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  6. #5
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Disabling Mouse in Qt?

    Well, mouse cursor can bi hidden with bios service 33h. Function code is 2. That means:
    Qt Code:
    1. mov ax, 02
    2. int 33h
    To copy to clipboard, switch view to plain text mode 

    will hide mouse cursor and disable mouse, regardless of port. This method is way low level, but efficent.
    Qt 5.3 Opensource & Creator 3.1.2

  7. #6
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Disabling Mouse in Qt?

    Quote Originally Posted by MarkoSan View Post
    Well, mouse cursor can bi hidden with bios service 33h. Function code is 2. That means:
    Qt Code:
    1. mov ax, 02
    2. int 33h
    To copy to clipboard, switch view to plain text mode 

    will hide mouse cursor and disable mouse, regardless of port. This method is way low level, but efficent.
    How to disable mouse port in Linux?
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  8. #7
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Disabling Mouse in Qt?

    This approach work on all pc computers, regardless of operating system. However, I think you must write assembler program and to "touch" bios you must be careful because you are turning to kernel mode.
    Qt 5.3 Opensource & Creator 3.1.2

  9. #8
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Disabling Mouse in Qt?

    Quote Originally Posted by MarkoSan View Post
    This approach work on all pc computers, regardless of operating system. However, I think you must write assembler program and to "touch" bios you must be careful because you are turning to kernel mode.
    But It only hides the mouse. I want to disable the mouse port for a specified amount of time.

    plz give me a example for this purpose or link.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  10. #9
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Disabling Mouse in Qt?

    From my experience, the mouse is disabled if this bios function is called. I've done it and it worked in good old DOS.
    Qt 5.3 Opensource & Creator 3.1.2

  11. #10
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Disabling Mouse in Qt?

    Quote Originally Posted by MarkoSan View Post
    From my experience, the mouse is disabled if this bios function is called. I've done it and it worked in good old DOS.
    I have also done in DOS and windows OS; but I don't know how to do this in Linux.
    Can u give me any link or example to do this.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  12. #11
    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: Disabling Mouse in Qt?

    What do you need the functionality for? If you want to do it on Linux, you have to have superuser privileges, otherwise forget it, it won't work. I don't know why it doesn't work when you grab the mouse, maybe it grabs the pointer only within the current application and your GTK widget is another application. In that case you need an appropriate Xlib call to grab the mouse for the whole desktop or filter out mouse events that are received by the server.

  13. #12
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Disabling Mouse in Qt?

    Quote Originally Posted by wysota View Post
    What do you need the functionality for? If you want to do it on Linux, you have to have superuser privileges, otherwise forget it, it won't work. I don't know why it doesn't work when you grab the mouse, maybe it grabs the pointer only within the current application and your GTK widget is another application. In that case you need an appropriate Xlib call to grab the mouse for the whole desktop or filter out mouse events that are received by the server.
    Dear Sir!
    Where I get the Xlib call example to grab mouse?
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  14. #13
    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: Disabling Mouse in Qt?

    I didn't say such a call exists. But studying Xlib manual might be a good place to start looking for a solution.

Similar Threads

  1. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 05:34
  2. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 06:13
  3. Replies: 2
    Last Post: 24th July 2006, 18:36
  4. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 19:25
  5. setCanvas blocks mouse movement on QtCanvasView
    By YuriyRusinov in forum Qt Programming
    Replies: 8
    Last Post: 20th April 2006, 07:38

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.