Results 1 to 3 of 3

Thread: Check if current item is undemouse() crash!?!?!?

  1. #1
    Join Date
    Jun 2010
    Posts
    100
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    13
    Thanked 1 Time in 1 Post

    Default Check if current item is undemouse() crash!?!?!?

    Hi!

    I want to see if the current widget is also under the mouse. I used the function this->mouseGrabber()->underMouse() which gives me a segmentation fault.

    then I tried this one:

    Qt Code:
    1. QWidget *w = new QWidget(this->mouseGrabber());
    2.  
    3. if(w->underMouse()){
    4. //Do something
    5. }
    To copy to clipboard, switch view to plain text mode 

    but it return me false...I believe this should work

  2. #2
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 13 Times in 13 Posts

    Default Re: Check if current item is undemouse() crash!?!?!?

    Try:
    Qt Code:
    1. QWidget *w = dynamic_cast<QWidget *>( this->mouseGrabber() );
    2.  
    3. if (w)
    4. {
    5. if (w->underMouse())
    6. {
    7. //Do something
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Jonny174 for this useful post:

    ruben.rodrigues (16th August 2011)

  4. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: Check if current item is undemouse() crash!?!?!?

    I want to see if the current widget is also under the mouse.
    Why not just :
    Qt Code:
    1. if( this->underMouse() ){
    2. // do something
    3. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 0
    Last Post: 10th March 2011, 12:44
  2. Can Qt check current audio status?
    By bizmopeen in forum Qt Programming
    Replies: 3
    Last Post: 5th November 2010, 03:58
  3. get and set current item in QTableView
    By pospiech in forum Newbie
    Replies: 8
    Last Post: 25th May 2009, 14:25
  4. How to check the current status of a service
    By Ankitha Varsha in forum Qt Programming
    Replies: 1
    Last Post: 21st October 2008, 13:55
  5. current item in treeview
    By kernel_panic in forum Qt Programming
    Replies: 2
    Last Post: 30th October 2007, 20:26

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
  •  
Qt is a trademark of The Qt Company.