Results 1 to 5 of 5

Thread: QWidget movable

  1. #1
    Join Date
    Feb 2007
    Posts
    32
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWidget movable

    Hi,
    If i have to make QWidget ( child widget ) movable then what i have to do?

  2. #2
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidget movable

    Quote Originally Posted by Pragya View Post
    Hi,
    If i have to make QWidget ( child widget ) movable then what i have to do?
    Please explain more...

  3. #3
    Join Date
    Feb 2007
    Posts
    32
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidget movable

    I want to make child Qwidget to work as Dockable widget that is floatable.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWidget movable

    Make sure it's geometry is not managed by a layout and reimplement corresponding mouse and/or key event handlers (depending on how it is supposed to be movable).

    Pseudo for mouse movement:
    Qt Code:
    1. // member variable
    2. QPoint offset;
    3.  
    4. mousePressEvent()
    5. {
    6. // offset from top left corner
    7. offset = event->pos();
    8. }
    9.  
    10. mouseMoveEvent()
    11. {
    12. // move to mouse pos - calculated offset
    13. move(mapToParent(event->pos()) - offset);
    14. }
    15.  
    16. mouseReleaseEvent()
    17. {
    18. // invalidate offset
    19. offset = QPoint();
    20. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWidget movable

    Quote Originally Posted by Pragya View Post
    I want to make child Qwidget to work as Dockable widget that is floatable.
    What do you mean? QDockWidget can be made floating.
    J-P Nurmi

Similar Threads

  1. Replies: 3
    Last Post: 8th March 2007, 14:54
  2. Showing QMainWindow without showing a child QWidget
    By discostu in forum Qt Programming
    Replies: 3
    Last Post: 4th March 2007, 09:03
  3. QTextEdit, sizeHint, QWidget
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 3rd February 2007, 08:25
  4. Replies: 1
    Last Post: 2nd May 2006, 21:11
  5. QScrollArea problem positioning a QWidget inside
    By Spectator in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 22:59

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.