Results 1 to 10 of 10

Thread: How to restrict a qml view to go out of the screen or main window by mouse dragging.

  1. #1
    Join Date
    Aug 2012
    Posts
    29
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default How to restrict a qml view to go out of the screen or main window by mouse dragging.

    Hi,

    I have a qml rectangle which opens up on a click event and I can move the window on the screen using mouse click and drag. Now the problem is I can move this qml out of the screen and it wont be visible and I can not close that.
    I want to restrict the movement of this qml to the screen area. or I canrestrict the mouse movement out of the screen area.
    any idea how to achieve this.

    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to restrict a qml view to go out of the screen or main window by mouse draggi

    Have a look at drag.minimumX, drag.maximumX properties in MouseArea element and their equivalents in vertical direction.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2012
    Posts
    29
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to restrict a qml view to go out of the screen or main window by mouse draggi

    thanks for the reply.
    I already used that, but after setting that my qml component itself is not being loaded. error message comes like "component is not ready".
    any other way?
    thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to restrict a qml view to go out of the screen or main window by mouse draggi

    If you get that message then it means your code has invalid syntax. Make sure you didn't do any syntax errors.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2012
    Posts
    29
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to restrict a qml view to go out of the screen or main window by mouse draggi

    sorry , actually i was getting that message for some other thing which I was trying for the same. but main thing is drag.minimumX, drag.minimumY, drag.maximumX, drag.maximumY isd not at all affecting.
    thanks.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to restrict a qml view to go out of the screen or main window by mouse draggi

    Quote Originally Posted by RJ View Post
    but main thing is drag.minimumX, drag.minimumY, drag.maximumX, drag.maximumY isd not at all affecting.
    Apparently you're not using it correctly. Show your code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Aug 2012
    Posts
    29
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to restrict a qml view to go out of the screen or main window by mouse draggi

    I have tried with the hard coced values also like
    MouseArea
    {
    drag.minimumX: 0
    drag.minimumY: 0
    drag.maximumX: 800
    drag.maximumY: 480
    }
    it should not allow mouse to move more than that, but it does.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to restrict a qml view to go out of the screen or main window by mouse draggi

    This does not restrict mouse movement. This restricts dragging to the bounds you specified in the drag.targets coordinate system.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Aug 2012
    Posts
    29
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to restrict a qml view to go out of the screen or main window by mouse draggi

    then what should I do for the mouse movement restriction?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to restrict a qml view to go out of the screen or main window by mouse draggi

    You cannot do that in QML. You have to use the native API.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to center main window on screen?
    By LarryP in forum Qt Programming
    Replies: 5
    Last Post: 24th July 2020, 21:29
  2. Replies: 1
    Last Post: 5th September 2013, 17:33
  3. main window gets wider than screen size
    By shanchathuranga in forum Qt Programming
    Replies: 1
    Last Post: 16th March 2012, 15:45
  4. Layouts and allowing view to stretch with main window
    By steg90 in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2007, 11:30
  5. Replies: 5
    Last Post: 7th November 2006, 16:01

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.