Results 1 to 8 of 8

Thread: Move Frameless Dialog

  1. #1
    Join Date
    Jan 2011
    Location
    Sri Lanaka
    Posts
    64
    Thanks
    39
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Move Frameless Dialog

    Hello,

    Any know how to move a Frameless QDialog?
    And can you please post a example code..

    Note:
    the QDialog i have is filled with Qwidgets.so mouse click event will set the focus on to Qwidget. not the Qdialog..

    Thank you..
    Last edited by deepal_de; 25th May 2011 at 10:09.

  2. #2
    Join Date
    Aug 2008
    Posts
    45
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Move Frameless Dialog

    Use this to move the dialog around:
    Qt Code:
    1. void QWidget::move ( int x, int y )
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to joyer83 for this useful post:

    deepal_de (25th May 2011)

  4. #3
    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: Move Frameless Dialog

    the QDialog i have is filled with Qwidgets.so mouse click event will set the focus on to Qwidget. not the Qdialog..
    use an even filter.
    ==========================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.

  5. The following user says thank you to high_flyer for this useful post:

    deepal_de (25th May 2011)

  6. #4
    Join Date
    Jan 2011
    Location
    Sri Lanaka
    Posts
    64
    Thanks
    39
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Move Frameless Dialog

    thanks for the reply...

    void QWidget::move ( int x, int y )
    this not the kind of example i had in mind, but thanks anyway

    here i have to calculate the mouse point offset know??
    that means if the user click middle of the dialog,
    i have to get the point of the mouse click and and mapToGloble,
    get the difference between the mouse click point and the form location..
    and do the math and then move the dialog...
    for this i have to catch the mouse press event and release event know..

    i was wondering if there is some other simple way to do this..
    any built-in mechanism to help move frame-less dialogs??

  7. #5
    Join Date
    Aug 2008
    Posts
    45
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Move Frameless Dialog

    Quote Originally Posted by deepal_de View Post
    this not the kind of example i had in mind, but thanks anyway
    You welcome, simple answer (for me) to a simple question.

    Quote Originally Posted by deepal_de View Post
    here i have to calculate the mouse point offset know??
    that means if the user click middle of the dialog,
    i have to get the point of the mouse click and and mapToGloble,
    get the difference between the mouse click point and the form location..
    and do the math and then move the dialog...
    for this i have to catch the mouse press event and release event know..

    i was wondering if there is some other simple way to do this..
    any built-in mechanism to help move frame-less dialogs??
    Yes, I'm afraid that if you remove the borders and title bar you have to implement everything by yourself.
    Easiest might be to create your own title bar as a widget and then reimplement the mouse event handlers of that widget. Or use the event filter instead of reimplementing.

  8. The following user says thank you to joyer83 for this useful post:

    deepal_de (26th May 2011)

  9. #6
    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: Move Frameless Dialog

    No, you will have to implement it your self, and frame less windows, by definition are not meant to be moved (usually used for splash screens), since there is no way to "hold" them, since they don't have a frame.
    ==========================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.

  10. The following user says thank you to high_flyer for this useful post:

    deepal_de (26th May 2011)

  11. #7
    Join Date
    Jan 2011
    Location
    Sri Lanaka
    Posts
    64
    Thanks
    39
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Move Frameless Dialog

    Thanks for the reply's.....

  12. #8
    Join Date
    Jan 2011
    Location
    Sri Lanaka
    Posts
    64
    Thanks
    39
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Move Frameless Dialog

    Qt Code:
    1. int iXdeffarace = -1;
    2. int iYdeffarance = -1;
    3. bool b_mousePressed;
    4.  
    5. void mydialog::mousePressEvent ( QMouseEvent * event)
    6. {
    7. b_mousePressed = true;
    8. QPoint qpMousePressedPoint = QCursor::pos();
    9. QPoint qpApploc = this->pos();
    10. iXdeffarace = qpMousePressedPoint.x() - qpApploc.x();
    11. iYdeffarance = qpMousePressedPoint.y() - qpApploc.y();
    12. }
    13.  
    14. //********************************************************
    15. void mydialog::mouseReleaseEvent ( QMouseEvent * event )
    16. {
    17. b_mousePressed = false;
    18. }
    19.  
    20. //********************************************************
    21. void mydialog::mouseMoveEvent ( QMouseEvent * event )
    22. {
    23. if(b_mousePressed)
    24. {
    25. QPoint qpAppNewLoc( (QCursor::pos().x() - iXdeffarace) , (QCursor::pos().y() - iYdeffarance) );
    26. this->setProperty("pos", qpAppNewLoc);
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Frameless dialogs on CE6
    By danielweberdlc in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 7th October 2010, 23:39
  2. Frameless QMdiSubWindow
    By meadmaker in forum Newbie
    Replies: 4
    Last Post: 14th September 2010, 12:28
  3. How to show a frameless dialog - DOESN'T WORK
    By franco.amato in forum Newbie
    Replies: 4
    Last Post: 2nd June 2010, 18:21
  4. Replies: 1
    Last Post: 22nd November 2008, 07:32
  5. Detecting end of dialog move
    By darryl in forum Qt Programming
    Replies: 20
    Last Post: 12th September 2006, 15:04

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.