Home c++ Qt C++ Graphics View Real Time Recruitment

Qt C++ Graphics View Real Time Recruitment

Author

Date

Category

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));
}

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions