I am a novice in Qt, and I want to draw anything in the graphics view in real time. Suppose I want to change the background color every second. I know that with Graphics View you can work using the MousePressEvent type features that are specified in advance. I am looking for something like the function Update (), which would be called every frame, and in which it would be possible to write drawing graphics including, but I could not find a similar on the Internet.
Answer 1
Cast timer and timer update background:
...
_View = New QGraphicsView;
_View- & gt; SetScene (New QGraphicsscene);
...
Qtimer * Timer = New Qtimer;
Connect (Timer, & amp; Qtimer :: Timeout, This, & Amp; Mainwindow :: Ontimeout);
Timer- & gt; start (1000); // 1 sec.
...
Void Mainwindow :: Ontimeout ()
{
_View- & gt; scene () - & gt; setbackgroundbrush (qbrush (qt :: black));
}