Results 1 to 4 of 4

Thread: QGraphicsView advantages of drawBackground and drawForeground?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2017
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QGraphicsView advantages of drawBackground and drawForeground?

    So I'm working on a map widget to place a drone on a map, and I don't understand all the existing code just yet. I'm wondering, as I can do

    Qt Code:
    1. QPainter(viewport());
    2. viewport()->rect();
    To copy to clipboard, switch view to plain text mode 

    to get a painter to draw things to the widget and to get the widget's geometric properties, what is the point of the functions void drawBackground(QPainter * painter, const QRectF & rect) and void drawForeground(QPainter * painter, const QRectF & rect) when one could just create their own functions to deal with specific events instead of 2 functions for all cases? Also, are these 2 functions called when the QGraphicsView recieves a call to update()?

    Is the benefit that when one calls drawForeground, it only replaces the items drawn in previous calls to drawForeground? In other words, If I were to draw a physical map of real world terrain in drawBackground, then call drawForeground each time the drone position changes, will it erase the drone drawn from the previous drawForeground before drawing another drone and without affecting the map? If I were to draw a picture from an image file with drawBackground that takes up the entire viewport, will it erase the stuff from the previous call to drawForeground?
    Last edited by Bla1; 21st July 2017 at 23:51.

Similar Threads

  1. What are the advantages of developing in Qt this 2017?
    By laurantx0ne in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2017, 21:34
  2. QGraphicsView\Scene drawBackground bitmap as geomap
    By pethead in forum Qt Programming
    Replies: 1
    Last Post: 29th October 2010, 13:45
  3. Advantages of commercial Qt other than licensing rights.
    By babu198649 in forum General Discussion
    Replies: 6
    Last Post: 23rd September 2008, 13:51
  4. QPainter and QGraphicsView drawBackground() override
    By forrestfsu in forum Qt Programming
    Replies: 4
    Last Post: 5th December 2006, 15:52

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.