Results 1 to 6 of 6

Thread: widgets not accepting hoverevents ?

  1. #1
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default widgets not accepting hoverevents ?

    Hi guys,

    I have some widgets and QGraphicsTextItem on my scene/view. I want those items/widgets not to accept any events(especially mouse events(like hover)). I have already done this for QGraphicsTExtItem:
    Qt Code:
    1. ...
    2. item->setAcceptsHoverEvents(false);
    3. item->setAcceptedMouseButtons(false);
    4. ...
    To copy to clipboard, switch view to plain text mode 

    but do not know howto disable mousehoverEvent for widgets. My widgets are transparent and every time I move to the widget I want my special cursor to be drawn under those widgets(on the scene), but nothing on the scene is drawn(under a widget) while moving the cursor on my widgets.
    Any ideas?(

    Thanks

    P.S>

    SetDisabled(false) do not work.
    setFocusPolicy(Qt::NoFocus) do not work either.
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: widgets not accepting hoverevents ?

    The only way is to install the view as event filter for the widgets and when you get any kind of mouse events for them forward them to the view. By forward I mean creating a new QMouseMoveEvent and post it in the view's event queue.

    I want my special cursor to be drawn under those widgets(on the scene),
    You can't make the mouse to be displayed *under* a widget. Maybe with some serious tweaking.

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

    Default Re: widgets not accepting hoverevents ?

    You can also reimplement event handlers for your widgets/items and ignore() the events there. Then they will be forwarded to their parents. You can also try clearing the WA_Hover attribute for your widgets, but this might not work.

  4. #4
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Thanked 38 Times in 30 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: widgets not accepting hoverevents ?

    Qt Code:
    1. ...
    2. item->setAcceptedMouseButtons(false);
    To copy to clipboard, switch view to plain text mode 

    This cannot possibly be correct. false is anything but 0, like possibly 1, but this function takes a Qt::MouseButtons argument. I presume you meant to pass 0. ;-)
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

  5. #5
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: widgets not accepting hoverevents ?

    Hi,

    Thanks for you ideas.
    I do not want the "cursor to be drawn" but while I am moving the cursor there are 2 lines (1 vertical and one horicontal) drawn on the scene, and the line move while I move the cursor. When the cursor in on my widgets the lines are not redrawn, and they should be redrawn under the widget, like it happens when I move the cursor near the widgets.

    I just need the widgets to ignore all mouse events, focus events, etc

    I presume you meant to pass 0. ;-)
    yes, you're right.

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  6. #6
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: widgets not accepting hoverevents ?

    Hi,

    I have solved the problem.
    I have widgets and labels(on that widgets) as my information panels. To achieve transparent wigets(accepting no events, transparent for events, actions, etc.) I have set :
    Qt Code:
    1. setMouseTracking(true);
    To copy to clipboard, switch view to plain text mode 

    and my widgets/and labels work as I wanted; what is needed is being drawn under those widgets and labels when I move cursor on a widget/label.

    Thank you.

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

Similar Threads

  1. Qt3 - Multiple transparent widgets
    By bythesea in forum Qt Programming
    Replies: 4
    Last Post: 11th September 2009, 11:24
  2. widgets behind hidden widgets not working
    By bpetty in forum Newbie
    Replies: 13
    Last Post: 7th September 2007, 20:23
  3. Performance in hiding/showing widgets
    By Paalrammer in forum Newbie
    Replies: 12
    Last Post: 14th February 2007, 18:57
  4. Replies: 11
    Last Post: 7th July 2006, 13:09
  5. Creating Widgets
    By hylke in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2006, 08:37

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.