Results 1 to 8 of 8

Thread: EnterEvent and LeaveEvent don't work perfectly

  1. #1
    Join Date
    Apr 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: EnterEvent and LeaveEvent don't work perfectly

    Hello, my problem is the next. I want a hover (enterEvent) effect and an animated hide effect (leaveEvent) with EnterEvent and LeaveEvent.
    That works fine on the early, but if I do 5-6 really fast call, can not be called anymore anyone Event

    Qt Code:
    1. timer2 = new QTimer(this);
    2. connect(timer2, SIGNAL(timeout()), this, SLOT(slowlyHide()));
    3.  
    4. void Clock::enterEvent(QEvent *event){
    5. dragButton->show(); //dragbutton is an extended qlabel
    6. update();
    7. }
    8. void Clock::leaveEvent(QEvent *event){
    9. if(!timer2->isActive())
    10. timer2->start(200);
    11. }
    12.  
    13. void Clock::slowlyHide(){
    14. dragButton->setOpacity(dragButton->getOpacity()/2);
    15. if(dragButton->getOpacity() < 5){
    16. timer2->stop();
    17. dragButton->setOpacity(255);
    18. dragButton->hide();
    19. }
    20. update();
    21. }
    To copy to clipboard, switch view to plain text mode 

    It's a bug or what?


    Added after 26 minutes:


    Gif: http://imageshack.us/photo/my-images/853/current2.gif/
    Last edited by krisztiantobias; 31st July 2012 at 14:32.

  2. #2
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: EnterEvent and LeaveEvent don't work perfectly

    Did you try to debug it?
    add qDebug("enter event") and qDebug("leave event") (outside the if statements) you can see if the event still gets triggered

    this has nothing to do with the problem, but maybe you can use a propertyanimation for a smooth fading out and in (for the extra oemf effect) .

  3. #3
    Join Date
    Apr 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: EnterEvent and LeaveEvent don't work perfectly

    Yeah, I tried.

    ...
    QEnterEvent(0x28d5d0)
    QLeaveEvent(0x28d7d4)
    QEnterEvent(0x28d5d0)
    A QEnterEvent is the last, after the program don't get more event with this code as well:

    Qt Code:
    1. void Clock::enterEvent(QEvent *event){
    2. qDebug() << event;
    3. }
    4. void Clock::leaveEvent(QEvent *event){
    5. qDebug() << event;
    6. }
    To copy to clipboard, switch view to plain text mode 

    If I open the context menu, the QLeaveEvent is coming, but until that nothing...
    Last edited by krisztiantobias; 31st July 2012 at 17:43.

  4. #4
    Join Date
    Apr 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: EnterEvent and LeaveEvent don't work perfectly

    After the 7. enterEvent the leaveEvent doesn't work...
    http://img32.imageshack.us/img32/201/bugr.gif

  5. #5
    Join Date
    Jun 2012
    Posts
    98
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: EnterEvent and LeaveEvent don't work perfectly

    Here's what I've thought of:
    -Enter and leave events won't work if something grabs the mouse
    -What happens when you enter and leave and enter again? The timer doesn't get restarted, it looks like it just keeps doing it's thing.
    Maybe something breaks because of this.
    -Is it always 7? Try it at different speeds, different numbers of times, etc.. These will reveal the type of problem it is. If it's always 7 it has to do with some limitation in somethings structure (probably), if it's always a certain amount of time, or happens only if you do it quickly (or something) you're timer is probably screwed up some how.
    --By this I mean try it really slowly one time then really fast another time; see if you can predict how and when it will fail.


    Also, I don't think your code would slowly fade. It looks like the timer times out, and then makes the thing less opaque than it was by a factor of 2. You'd have to leave the clock like 6 times (waiting each time) for it to fade; at least that's what it looks like.

    That's all I can think of.

  6. #6
    Join Date
    Apr 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: EnterEvent and LeaveEvent don't work perfectly

    Quote Originally Posted by tescrin View Post
    -Enter and leave events won't work if something grabs the mouse
    You can see, nothing happened.

    Quote Originally Posted by tescrin View Post
    -What happens when you enter and leave and enter again? The timer doesn't get restarted, it looks like it just keeps doing it's thing.
    Maybe something breaks because of this.
    No, that gif was without any code. In the events was only qDebug and a counter.

    Quote Originally Posted by tescrin View Post
    -Is it always 7? Try it at different speeds, different numbers of times, etc.. These will reveal the type of problem it is. If it's always 7 it has to do with some limitation in somethings structure (probably), if it's always a certain amount of time, or happens only if you do it quickly (or something) you're timer is probably screwed up some how.
    No, it's absolutely random (1-20)

    Quote Originally Posted by tescrin View Post
    Also, I don't think your code would slowly fade. It looks like the timer times out, and then makes the thing less opaque than it was by a factor of 2. You'd have to leave the clock like 6 times (waiting each time) for it to fade; at least that's what it looks like.
    The timer doesn't work, that was without timer...

    The OS is W7 64 bit, maybe that is the problem, I really don't know...

  7. #7
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: EnterEvent and LeaveEvent don't work perfectly

    Is it possible to upload a compilable version, so i can try it. (running w7 64-bit and ubuntu)

  8. #8
    Join Date
    Apr 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: EnterEvent and LeaveEvent don't work perfectly

    I choosed an another way, so it's does not matter...

Similar Threads

  1. Replies: 2
    Last Post: 19th July 2012, 23:02
  2. enterEvent / leaveEvent on Widget really slow on MacOSX
    By RThaden in forum Qt Programming
    Replies: 1
    Last Post: 14th February 2012, 10:54
  3. Make image bigger on enterEvent, maller on leaveEvent
    By Globulus in forum Qt Programming
    Replies: 4
    Last Post: 10th August 2011, 15:38
  4. enterEvent, leaveEvent, setWindowFlags
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 3rd February 2007, 09:15
  5. Subclassed QLabel and enterEvent
    By Lykurg in forum Qt Programming
    Replies: 2
    Last Post: 29th August 2006, 06:44

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.