Results 1 to 5 of 5

Thread: How to restrict graphic items in view

  1. #1
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to restrict graphic items in view

    I want to know if i can restrict graphics items within a region of the view.
    I want that items should not be moved beyond a point in the view. Is there some inbuilt function to do so ? Or I have to implement my own code for that ??

    I have tried setSceneRect, but it just restricts the scrollbars, not dragging of the items.
    Also if someone can throw light on setFrameRect ? I didnt understand it much
    playing with setFrameRect just showed part of the view area, I cudnt get with reference to what the frame rect is set ?

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: How to restrict graphic items in view

    Can anyone just tell if I have to implement restricting the items myself ??
    I have tried various inbuilt functions but withoout the desired effect

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

    Default Re: How to restrict graphic items in view

    Quote Originally Posted by aamer4yu View Post
    Can anyone just tell if I have to implement restricting the items myself ??
    Yes, you probably do, but it should be easy - just reimplement mouse move event for your item.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to restrict graphic items in view

    I will try that...
    Before that I was trying dragMoveEvent.

    As an example, I built another application, involving a CScene,CView,and CItem , derived from QGraphicsScene, QGraphicsView and QGraphicsItem respectively.
    I overrided dragMoveEvent in all three classes. But I find that the program doesnt enter any of the three overloaded functions when I drag an item in the scene
    In what case is dragMoveEvent called ??
    and i guess mouseMoveEvent is triggered when I drag an item. Why isnt dragMoveEvent called ??

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

    Default Re: How to restrict graphic items in view

    drag events are meant for drag&drop operations. You have to specifically enable dragging items for these events to be sent. In "usual" situations you should use mousePress/Move/Release events.

Similar Threads

  1. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 12:20
  2. Drag and drop items in view to sort order
    By Big Duck in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2006, 19:43
  3. Replies: 6
    Last Post: 20th April 2006, 10:23

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.