Results 1 to 9 of 9

Thread: QWidget movement

  1. #1
    Join Date
    Jan 2010
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Smile QWidget movement

    Hello,
    I am trying to catch the event when my window is being moved by the user.
    I want to make my widget semi-visible while moving.

    The moveevent only gives position updates not status.
    And mouse events cannot be catched from title bar.
    Qt::WA_PendingMoveEvent is also not set when moving the widget.

    Please help,

  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: QWidget movement

    The moveevent only gives position updates not status.
    What do you mean by 'status'?
    ==========================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
    Jan 2010
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QWidget movement

    moveEvent gives old and new positions but I couldn't finf a way to get the moving status.

  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: QWidget movement

    What is 'moving status'?
    ==========================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: QWidget movement

    hi,
    @high_flyer,
    i think , he wants to know
    1)how to know, when the user started to move the window(this is pretty easy, moveEvent will help) (window move started)
    2)how to know, user stops moving the window. (window move ended)
    I want to make my widget semi-visible while moving.
    his goal is to show a transparent window, when it is moved.

    @fakefish:
    just a hints, not the direct answer though, we can use moveevent and a timer or eventfilter to achieve the goal.(not the best logic though)
    Bala

  6. The following user says thank you to BalaQT for this useful post:

    fakefish (7th April 2011)

  7. #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: QWidget movement

    In that case you can use mouseReleaseEvent to know when user let go of the window.
    mouseMoveEvent() will tell you when it started.
    ==========================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.

  8. #7
    Join Date
    Jan 2010
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QWidget movement

    Quote Originally Posted by high_flyer View Post
    In that case you can use mouseReleaseEvent to know when user let go of the window.
    mouseMoveEvent() will tell you when it started.
    Widget does not capture mouse events on the title bar.


    Added after 17 minutes:


    Quote Originally Posted by BalaQT View Post
    @fakefish:
    just a hints, not the direct answer though, we can use moveevent and a timer or eventfilter to achieve the goal.(not the best logic though)
    Bala
    Thanks, I tried it does not seem bad, but its processor usage is huge
    Last edited by fakefish; 7th April 2011 at 13:51.

  9. #8
    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: QWidget movement

    hi,
    Thanks, I tried it does not seem bad, but its processor usage is huge
    how about this, install a eventfilter and start the timer only at the window move event.

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent)
    3. {
    4. bMove=false;
    5. connect(&t,SIGNAL(timeout()),this,SLOT(Trans()));
    6. t.setInterval(50);
    7. installEventFilter(this);
    8. }
    9. bool MainWindow::eventFilter(QObject *obj, QEvent *evt)
    10. {
    11. bMove=false;
    12. if(evt->type()==QEvent::Move)
    13. {
    14. bMove=true;
    15. if(!t.isActive())
    16. {
    17. t.start();
    18. }
    19. }
    20. }
    21.  
    22. void MainWindow::Trans()
    23. {
    24. if(bMove)
    25. {
    26. //make window transparent
    27. }
    28. else
    29. {
    30. t.stop();
    31. //make window normal
    32. }
    33. }
    To copy to clipboard, switch view to plain text mode 

    not a straight forward solution, but hope it helps,
    bala

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

    fakefish (19th April 2011)

  11. #9
    Join Date
    Jan 2010
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QWidget movement

    Quote Originally Posted by BalaQT View Post
    how about this, install a eventfilter and start the timer only at the window move event.
    Thanks that also worked. The CPU usage increase caused by repainting transparent window, I believe.

    Fakefish

Similar Threads

  1. free movement in QListView
    By Algos in forum Qt Programming
    Replies: 1
    Last Post: 1st August 2010, 04:08
  2. line movement
    By zgulser in forum Qt Programming
    Replies: 7
    Last Post: 17th August 2009, 18:01
  3. Can we restrict the movement of a Qt Window?
    By Frank J. Lhota in forum Qt Programming
    Replies: 4
    Last Post: 21st October 2008, 20:34
  4. Block Widget Movement
    By shyam prasad in forum Qt Programming
    Replies: 5
    Last Post: 3rd April 2007, 18:27
  5. Game mouse movement
    By chaosgeorge in forum Qt Programming
    Replies: 1
    Last Post: 2nd December 2006, 23:41

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.