Results 1 to 3 of 3

Thread: Mouse dragged widget without title

  1. #1
    Join Date
    Nov 2006
    Location
    Russian Federation, Novosibirsk
    Posts
    7
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question Mouse dragged widget without title

    How to create mouse dragged widget without title?

  2. #2
    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: Mouse dragged widget without title

    Reimplement QWidget::mousePressEvent() and QWidget::mouseMoveEvent().

    Here's some "pseudo":
    Qt Code:
    1. // a frameless window
    2. setWindowFlags(Qt::FramelessWindowHint);
    3.  
    4. // member variable
    5. QPoint offset;
    6.  
    7. mousePressEvent()
    8. {
    9. // offset from top left corner
    10. offset = event->pos();
    11. }
    12.  
    13. mouseMoveEvent()
    14. {
    15. // move to mouse pos - calculated offset
    16. move(event->globalPos() - offset);
    17. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Nov 2006
    Location
    Russian Federation, Novosibirsk
    Posts
    7
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Mouse dragged widget without title

    Thank you!

Similar Threads

  1. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 06:13
  2. Replies: 2
    Last Post: 24th July 2006, 18:36
  3. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 19:25
  4. Forwarding mouse events to another widget.
    By yogeshm02 in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2006, 13:25
  5. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16

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.