Results 1 to 9 of 9

Thread: Mainwindow winks

  1. #1
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    30
    Thanked 4 Times in 4 Posts

    Question Mainwindow winks

    Hi to all:
    I use the following codes to hide my mainwindow when the mouse leave it, and show it when the mouse enter it. but when the mouse enter the mainwindow, it wrinks all the time.
    Qt Code:
    1. //mouse leave
    2. void EasyGo::leaveEvent(QEvent *)
    3. {
    4. //如果主界面靠近屏幕上边缘,则进入上边缘以上
    5. QPoint leftTop = pos();
    6. if(leftTop.y() < 6)
    7. {
    8. move(leftTop.x(), -frameGeometry().height() + 6);
    9. return;
    10. }
    11. }
    12.  
    13. //mouse enter
    14. void EasyGo::enterEvent(QEvent *)
    15. {
    16. QPoint leftTop = pos();
    17. if(leftTop.y() < 0)
    18. {
    19. move(leftTop.x(), 0);
    20. update();
    21. return;
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 

    any idea appreciated.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: Mainwindow winks

    Wouldnt it be better if you hide/show you widget on mouse events in the parent window ?
    I mean once you hide you window on mouse leave, how do you expect to get enter event ?

    I guess it will be better if you trap some area in parent widget and show/hide your window accordingly.

  3. #3
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    30
    Thanked 4 Times in 4 Posts

    Default Re: Mainwindow winks

    yeah, but, this is my top level window, so it has no parent window.
    Thanks

  4. #4
    Join Date
    Oct 2008
    Posts
    306
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    6
    Thanked 9 Times in 8 Posts

    Default Re: Mainwindow winks

    You could set opacity to zero... but I don't know if that uses more cpu/ram....?
    Last edited by been_1990; 9th May 2009 at 20:05.

  5. #5
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    30
    Thanked 4 Times in 4 Posts

    Default Re: Mainwindow winks

    yeah, it does use more cpu and arm.
    thanks!!

  6. #6
    Join Date
    Oct 2008
    Posts
    306
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    6
    Thanked 9 Times in 8 Posts

    Default Re: Mainwindow winks

    So.. whats your solution?

  7. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: Mainwindow winks

    I guess changing opacity on enter and leave event would be better as it happens in Winamp.
    If you try to hide the window, how do you expect to bring it back ? You will need to monitor the mouse events on the desktop and then bring back your application, which I think would be heavy task for a simple application.

  8. #8
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    30
    Thanked 4 Times in 4 Posts

    Default Re: Mainwindow winks

    I have to setMaxmunSize and minimunsize of the window when the mouse enters or leaves the window, i.e, I when the mouse leaves the window, set the window to a smaller one, and set it back to the original size when the mouse enters again.
    But, it's not what I want to use……

  9. #9
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    30
    Thanked 4 Times in 4 Posts

    Default Re: Mainwindow winks

    I have to setMaxmunSize and minimunsize of the window when the mouse enters or leaves the window, i.e, I when the mouse leaves the window, set the window to a smaller one, and set it back to the original size when the mouse enters again.
    But, it's not what I want to use……

Similar Threads

  1. Child Widgets In MainWindow
    By RY in forum Newbie
    Replies: 3
    Last Post: 4th October 2008, 09:39
  2. mainwindow modality
    By user in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2008, 01:54
  3. Notifying Mainwindow of an event..
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 9th November 2007, 22:29
  4. Replies: 1
    Last Post: 11th September 2007, 14:34
  5. Replies: 3
    Last Post: 23rd July 2006, 19:02

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.