I have two questions.
What is the difference between
paint()
ofQGraphicsItem
andpaintEvent()
ofQWidget
APIs?I am developing a timer kinda GUI, so I am updating the screen every 100ms with
paint()
API on embedded linux board. It consumes almost all of the CPU. Any idea how to prevent this?
Or is there any other method to do this simple graphics?
- Also I have multiple
QGraphicsScene
each with its ownQGraphicsView
in a grid layout. How to update the individual view from the MainWindow.
Below is the code how I currently do this:
/****SCENE 1*****/
scene_1 = new QGraphicsScene();
scene_1->setBackgroundBrush(Qt::black);
ui->gv_1->setScene(scene_1);
ui->gv_1->setRenderHint(QPainter::Antialiasing);
circle = scene_1->addEllipse(50, 80, 150, 150, outlinePen, darkGreyBrush);
textSlotNo = scene_1->addText("1", QFont("Arial", 30) );
textSlotNo->setDefaultTextColor(Qt::gray);
textSlotNo->setPos(0,50);
MyItem *item_1 = new MyItem(1);
scene_1->addItem(item_1);
item_1->timer = new QTimer();
connect(item_1->timer, SIGNAL(timeout()),scene_1, SLOT(update()));
item_1->timer->start(100);
/****SCENE 2*****/
......
Hardware: TI-AM3354