Results 1 to 5 of 5

Thread: How to disable Mouse pointers on particular QWidget

  1. #1
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up How to disable Mouse pointers on particular QWidget

    Hi all,

    Now i am using QT 4.2 , I want to disable mouse action when mouse pointer moves to particular Widget, and when it moves to another widget it should be enabled,

    If anybody knows please help me.

    Thanks
    Rajesh.S

  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: How to disable Mouse pointers on particular QWidget

    What is "mouse action"? Perhaps you could disable the widget?
    J-P Nurmi

  3. #3
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to disable Mouse pointers on particular QWidget

    Quote Originally Posted by rajeshs View Post
    Hi all,

    Now i am using QT 4.2 , I want to disable mouse action when mouse pointer moves to particular Widget, and when it moves to another widget it should be enabled,

    If anybody knows please help me.

    Thanks
    Rajesh.S
    I guess there are no direct method to do. Probably you create your own cursor which is blank and set for the widget. This sounds crude but anyway try this. You might need to ignore all the mouse events if you dont want the widget to be disabled.
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class Widget : public QWidget
    4. {
    5. public:
    6. Widget(QWidget *par=0) : QWidget(par)
    7. {
    8. QBitmap bitmap(32,32);
    9. bitmap.fill(Qt::color0);//initialize every thing to 0 bit
    10. QCursor cursor(bitmap,bitmap);//blank cursor
    11. setCursor(cursor);
    12. }
    13.  
    14. bool event
    15. };
    16.  
    17. int main(int argc, char *argv[])
    18. {
    19. QApplication app(argc, argv);
    20. Widget w;
    21. w.show();
    22. return app.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

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

    rajeshs (1st July 2007)

  5. #4
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: How to disable Mouse pointers on particular QWidget

    Thak you For your Replies,

    I got another direct solution, we can use like following ,

    int main(int argc,char *argv[])
    {
    QApplication app(argc,argv);
    QMainWindow* wid=new QMainWindow;
    app.setOverrideCursor(Qt::BlankCursor);
    wid->show();
    return app.exec();
    }
    Thanks,
    Rajesh.S

  6. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to disable Mouse pointers on particular QWidget

    Quote Originally Posted by rajeshs View Post
    app.setOverrideCursor(Qt::BlankCursor);
    lol. Never thought of searching for it after going through some unneeded cursors in the predefined cursor list.
    Good that you found out a more elegant solution.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  7. The following user says thank you to Gopala Krishna for this useful post:

    rajeshs (2nd July 2007)

Similar Threads

  1. Disable QTextCursor Mouse click repositioning
    By VireX in forum Qt Programming
    Replies: 2
    Last Post: 3rd April 2007, 08:08
  2. Replies: 1
    Last Post: 9th February 2007, 09:41
  3. How to disable maximum event in QWidget??
    By hesummar in forum Qt Programming
    Replies: 2
    Last Post: 28th October 2006, 13:21

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.