Results 1 to 11 of 11

Thread: Disable Move option in window

  1. #1
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Disable Move option in window

    hi,
    Im using qt4.0 in debian. i want to disable the move in every window.
    im using QDialog , QMainwindow. im using frameless window,but when i use alt+spacebar , i can able to move the window.
    Is there any way to disable the move option

    Thnks
    Bala

  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: Disable Move option in window

    You can override the move event, and move the window back to its position every time it gets moved.
    ==========================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.

  3. #3
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Disable Move option in window

    Thnks for the reply

    any examples pls

    Bala

  4. #4
    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: Disable Move option in window

    read the documentation for QWidget::moveEvent()
    http://doc.trolltech.com/4.5/qwidget.html#moveEvent
    ==========================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. #5
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Disable Move option in window

    hi, highflyer,

    i wrote the below code, idea is working but system was hanged .
    any other ways to solve?

    void MainWindow::moveEvent(QMoveEvent *event)
    {
    this->move(0,0);
    }

    Bala

  6. #6
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Disable Move option in window

    Quote Originally Posted by BalaQT View Post
    hi, highflyer,
    i wrote the below code, idea is working but system was hanged .
    any other ways to solve?
    Bala
    Try this:
    Qt Code:
    1. void MainWindow::moveEvent(QMoveEvent *event)
    2. {
    3. event->ignore();
    4. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Disable Move option in window

    hi yogesh
    event.ignore() is not working. below is my code

    void MainWindow::moveEvent(QMoveEvent *event)
    {
    event->ignore();
    }

    Thnks
    Bala

  8. #8
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Disable Move option in window

    come on, read the docs for move() and QMoveEvent! Work with QMoveEvent::oldPos() (As it is mentioned in the docs for QWidget::moveEvent()!!!)


    And if you are not able to solve such an easy task, please use the Newbie section next time. We will help you also there...

  9. #9
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Disable Move option in window

    hi lykurg,
    Thnks for the reply. pls understand my question.
    i have tried oldpos() and move(0,0),ignore()
    but oldpos(),ignore() is not working completely.
    move(0,0) is working but the system hangs on.

    Below is my code
    Qt Code:
    1. void MainWindow::moveEvent(QMoveEvent *event)
    2. {
    3. pos()=event->oldPos();
    4. //event->ignore();
    5. //this->move(0,0);
    6. //this->pos().setX(0);
    7. //this->pos().setY(0);
    8. }
    To copy to clipboard, switch view to plain text mode 

    The control goes to moveevent when im moving the window. but im not getting the desired results.

    how to disable the MOVE option in the MENU ,[which comes by pressing ALT-SPACEBAR] ?

    I want to have a FIXED window, which cannot be moved.
    pls direct me to solve this problem
    Thnks
    Bala

  10. #10
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Disable Move option in window

    Qt Code:
    1. void XXX::moveEvent(QMoveEvent *event)
    2. {
    3. if (QPoint(100,100) != event->pos())
    4. move(QPoint(100,100));
    5. }
    To copy to clipboard, switch view to plain text mode 

    or you can use a frameless window.

  11. The following user says thank you to Lykurg for this useful post:

    BalaQT (27th December 2009)

  12. #11
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Disable Move option in window

    Thnks Lykurg
    Its working.
    I want one more option.
    since the EVENT places the form in new position,
    the form is flickering while trying to MOVE. The window is fixed but flickering occurs.
    Is there any way to Disable the MOVE option in the MENU [which comes by pressing ALT + SPACE BAR.]
    My window is : Frameless MDI window.

    im using the setWindowFlags(Qt::FramelessWindowHint);
    But it will be helpful,if we can disable the MOVE option in the menu.

    Thnks
    Bala
    Last edited by BalaQT; 27th December 2009 at 11:52.

Similar Threads

  1. Double click resize window disable
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2008, 11:35
  2. How do I natively move a QWidget top-level window?
    By codeslicer in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2008, 21:08
  3. Replies: 1
    Last Post: 9th February 2007, 09:41
  4. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41
  5. Move window in Clone Mode
    By ultrabrite in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2006, 18:22

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.