Results 1 to 2 of 2

Thread: how can i restrict a widget to move beyond the task bar (in windows) and menubar(OSX)

  1. #1
    Join Date
    Feb 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default how can i restrict a widget to move beyond the task bar (in windows) and menubar(OSX)

    there are widgets in my app which are derived from a custom widget in my app. now i want the widgets not to move beyond the visible screen area.because if it moves beyond that the user will not be able to drag it back and close it through close button.

    how to achieve that. I tried to do that as in following code in the event filter of the custom widget:

    Qt Code:
    1. //check that the new position is with in available range
    2. QDesktopWidget *desktop = QApplication::desktop();
    3. QRect desktopRect = desktop->availableGeometry();
    4.  
    5. if(desktopRect.contains(keyEvent->globalPos())){
    6. this->move(this->pos() + (keyEvent->globalPos() - mLastMousePosition));
    7. mLastMousePosition = keyEvent->globalPos();
    8. return true;
    9. }
    To copy to clipboard, switch view to plain text mode 

    This is not working. Where I am doing wrong.
    Pls, show me a way to acheive this.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: how can i restrict a widget to move beyond the task bar (in windows) and menubar(

    because if it moves beyond that the user will not be able to drag it back and close it through close button.
    But how can that happen?
    In order to drag the window outside the desktop your mouse needs to be able to get out of the desktop, and that is not possible (at least not in the normal case).
    So, a situation that your widget/window comes out of the reach of your mouse is not possible...
    Or please explain how it is.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Modal dialog should not get hide behind windows task bar
    By sanjayshelke in forum Qt Programming
    Replies: 0
    Last Post: 11th September 2009, 16:08
  2. Move the menuBar() to the system menu
    By jlbrd in forum Qt Programming
    Replies: 3
    Last Post: 6th March 2009, 10:38
  3. Small task for Windows programmers
    By wysota in forum General Discussion
    Replies: 23
    Last Post: 29th October 2007, 09:32
  4. widget blinking at task bar
    By lawrence in forum Qt Programming
    Replies: 1
    Last Post: 19th January 2007, 11:30
  5. Is it possible to move main menubar down?
    By gfunk in forum Qt Programming
    Replies: 10
    Last Post: 12th September 2006, 23:40

Tags for this Thread

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.