Results 1 to 2 of 2

Thread: QGraphicsScene and its virtual drawBackground()/drawForeground() functions

  1. #1
    Join Date
    Jan 2018
    Location
    India, Delhi
    Posts
    10
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsScene and its virtual drawBackground()/drawForeground() functions

    Hello, I'm making a very small 2D animation software which basically allows the user to import images from pc and then render them on a specific location.
    I'm using Qt's Graphics View Framework, the QGraphicsView is being used for displaying each frame of animation.
    The frame itself inherits QGraphicsScene, now this frame class also contains a list of objects to render.

    Now, I have multiple frames, which are being displayed on QGraphicsView, but the problem is my frame's drawBackground() or drawForeground() functions which I implemented aren't being called automatically unlike QGraphicsView's drawBackground() method.

    Can you please help me what I'm doing wrong, till I get some concrete solution, I'm following this approach
    Inside of my QGraphicsView's drawForeground() method, in executing this statement so as to update my frame repeatedly
    Qt Code:
    1. scene()->render(painter, sceneRect(), sceneRect() );
    To copy to clipboard, switch view to plain text mode 
    this is working but I just don't understand why I need to call render() and why not QGraphicsScene::drawForeground() is not being called automatically.
    Last edited by keshav2010; 26th March 2018 at 18:19.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QGraphicsScene and its virtual drawBackground()/drawForeground() functions

    Have you defined the overridden functions with exactly the same signatures as the virtual functions in QGraphicsScene? Are you drawing in scene coordinates as the documentation states? Have you run this in the debugger and confirmed that the functions are not being called? And it probably isn't relevant, but have you included the Q_OBJECT macro in your derived class definition?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 3
    Last Post: 26th July 2017, 00:35
  2. Replies: 9
    Last Post: 26th July 2012, 18:35
  3. Replies: 1
    Last Post: 5th September 2011, 21:26
  4. QGraphicsScene::drawForeground()
    By alpinista in forum Qt Programming
    Replies: 11
    Last Post: 20th November 2009, 14:06
  5. use painter in QGraphicsScene::drawForeground
    By jano_alex_es in forum Qt Programming
    Replies: 2
    Last Post: 20th November 2009, 13:32

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.