Home > Mobile >  Use the update update QPainter cost time is too long
Use the update update QPainter cost time is too long

Time:01-07

Asked 20 ms refresh rate, but on the development board to run 60 ms
# include "widget. H"
# include "ui_widget. H"
#include
#include
#include
Widgets: : widgets (QWidget * parent)
: QWidget (parent)
, the UI (new UI: : Widget)
{
The UI - & gt; SetupUi (this);
QTimer * timer=new QTimer ();
The connect (timer, SIGNAL (timeout ()), and this, SLOT (the update ()));
The timer - & gt; Start (20);
}

Widgets: : ~ Widget ()
{
Delete the UI;
}
Void Widget: : paintEvent (QPaintEvent *) {
QPainter painter (this);

,0,10,10 painter. DrawLine (0);
QDebug () & lt; }

CodePudding user response:

Update () have reduced frequency optimization, if you have forced to refresh request should use the repaint ()

CodePudding user response:

Repaint () is the same, no difference how many,

CodePudding user response:

Repaint () is called immediately paintEvent, if that is enough QTimer slot call to reach your requirements of frequency
You can try the QTimer timerType set into a Qt: : PreciseTimer, if still no CPU performance is not short of
  •  Tags:  
  • Qt
  • Related