QChart 和使用 QGradients 加速 OpenGL 渲染

QChart and using QGradients with accelerated OpenGL rendering

出了什么问题:

目前我的图表工作得很好,它有渐变,例如单色系列:

这工作正常,但是当我使用 fooSeries->setUseOpenGL(true) 在 3 系列上启用 openGL 加速(以获得更多性能)时,图表变成了这个:

如您所见,渐变系列的颜色变为黑色,而单色系列变为白色。此外,Rounded Caps 和 Rounded Joins 似乎也消失了。我做了一些实验,看看是什么原因造成的。

已尝试fixes/experimentation:


我给系列上色如下:

// fooGradient is a QLinearGradient described elsewhere as an example.
QBrush fooGradientPenBrush = QBrush(fooGradient);
fooPen = new QPen(fooGradientPenBrush, 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//There are actually 2 QPens for two separate gradients in the program, but this is just for the example.

QBrush barPenBrush = QBrush(QRgb(0xFFFFFF));
barPen = new QPen(barPenBrush, 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

然后将这些笔放在各自系列的顶部:

fooSeries->setPen(*fooPen);
barSeries->setPen(*barPen);

然后将它们附加到图表中。而已。我会继续试验并查看文档,看看是否遗漏了什么,可能只是 openGL 加速只接受纯色,但据说在文档中找不到我可以找到的地方。如果有人想看一下 here.

,我会在 setUseOpenGl 文档中留下 link

经过更多研究,我似乎遗漏了文档中的一个重要细节:

Pen styles and marker shapes are ignored for accelerated series. Only solid lines and plain scatter dots are supported. The scatter dots may be circular or rectangular, depending on the underlying graphics hardware and drivers.

我仍然想知道是否有办法实现圆角以及不加速线条的方法。