Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt graphics performance on soft-float ARM?

I would like to create a car dashboard-like Qt interface (gauges, dials, knobs, etc). My device has a 800x480 LCD powered by a imx287 ARM SoC (armv5te with no hardware float, or GPU).

The problem im having is its very slow. A single gauge (background PNG image, with rotating PNG dial image) drawn at 20fps uses a ~20% CPU time. Adding a single rendered text string increases that up to 40% CPU use.

Im using QGraphicsScene which i uses a lot of floating point calcs... a problem since my SoC has no hardware float ability.

Are there any alternatives to QGraphicsScene that would work well for me?

This is what im currently doing:

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

bg.load("rpm.png");
needle.load("needle.png");

scene = new QGraphicsScene(this);
scene->setSceneRect(0,0, 800,480);

scene->addPixmap(bg);

needleItem = scene->addPixmap(needle);
needleItem->setPos(400-4,17);

textItem = scene->addText(tr(""), QFont("utsaah", 50, QFont::Bold, true));
textItem->setDefaultTextColor(QColor(255,255,255));
textItem->setPos(430, 360);

ui->graphicsView->setScene(scene);

thread = new UpdateDialsThread(this);
connect(thread, SIGNAL(updateDials()), this, SLOT(updateDials()));
thread->start();
}

void MainWindow::updateDials(void)
{
static int deg = 180;

deg += 1;
if (deg > 180+270)
    deg = 180;

QTransform trans;
trans.translate(needleItem->boundingRect().width()/2, needleItem->boundingRect().height());
trans.rotate(deg, Qt::ZAxis);
trans.translate(-needleItem->boundingRect().width()/2, -needleItem->boundingRect().height());
needleItem->setTransform(trans);

textItem->setPlainText(tr("%1").arg(deg*10, 4, 'f', 0));
}

Thanks in advance!

like image 841
thecoder Avatar asked Feb 14 '26 08:02

thecoder


1 Answers

I recommend to Use QML instead of QGraphicsView. You can create custom gauges with eye-catching animations with good performance. You can also have spring and damping effects. You can take a look at Dial Control Example.

like image 74
Nejat Avatar answered Feb 17 '26 01:02

Nejat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!