Results 1 to 4 of 4

Thread: view, scene and one moving item all around the scene/view...

  1. #1
    Join Date
    Jun 2014
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Talking view, scene and one moving item all around the scene/view...

    hey folks,

    will make it short...read all your answers here, couldn't find any solution for my question. I think I don't need to post any code snippets..this problem is to trivial..

    In my widget, I create a scene - in this scene, there is a view. Then, I add a self-created QGraphicsItem. This QGraphicsItem is movable like a car or so. Means, you can press W,A,S,D and this item moves forward,backward, sideways(rotates)...so far so good. Functions properly.

    But I am totally not able to make ensureVisible, centerOn, fitInView eg. function properly. Means, everytime my item is about to leave the visible area, the portview or so should be readjusted...

    You know what I mean? Thanks for your attention!

    greetings, Klaus

  2. #2
    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: view, scene and one moving item all around the scene/view...

    What have you tried so far?
    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
    Jun 2014
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: view, scene and one moving item all around the scene/view...

    Hello, thank you for your response

    As I said, I subclassed QGraphicsItem with the paint() and advanced()-functions. In paint() I call ensureVisible(boundingRect()) ... So far..this seems to function..but not with the margins for x and y. The given margins seem not to be recognized...

    I've tried to place ensureVisible() in the constructor, in main(), in advance(), ... tried it with a given sceneRect and without - and same with centerOn and fitInView .
    Tried it to map some coordinates to the scene, tried to discover when my item leaves the scene/view ... nothing.
    Last edited by KBuschder; 10th June 2014 at 16:08.

  4. #4
    Join Date
    Jun 2014
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: view, scene and one moving item all around the scene/view...

    Got the solution.

    I only had to set the sceneRect AND place the view/item with centerOn in the middle of the scene, so ensureVisible works quite fine!

    Thank you for your interest!

Similar Threads

  1. Replies: 1
    Last Post: 28th November 2011, 19:18
  2. View,Scene and RectItem
    By salmanmanekia in forum Newbie
    Replies: 2
    Last Post: 29th March 2010, 15:31
  3. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 20:21
  4. Graphics View - Scene & Item hierarchy
    By mooreaa in forum Qt Programming
    Replies: 0
    Last Post: 30th June 2008, 00:49
  5. how to zoom out item in View/Scene
    By nileshsince1980 in forum Qt Programming
    Replies: 7
    Last Post: 28th December 2007, 11:24

Tags for this Thread

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.