gpt4 book ai didi

c++ - 如何在视网膜显示器上使用 QPainter、QOpenGLPaintDevice 和 QOpenGLWidget 流畅地绘制?

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:40:30 25 4
gpt4 key购买 nike

<分区>

当我尝试使用 QWidgetQPainter 绘图时,绘图非常缓慢。我决定使用 QOpenGLPaintDeviceQOpenGLWidget 来加速绘图。但是形状的圆角与在常规 widget 上绘制相比非常粗鲁。

Q微件:

enter image description here

QOpenGLWidget:

enter image description here

这是我如何设置 QOpenGLPaintDevice 的代码。

QOpenGLPaintDevice* device = nullptr;

void QOpenGLWorkspaceWidget::resizeGL(int w, int h) {
initDeviceIfNeed();
handleResize(this, w, h);
int ratio = devicePixelRatio();
device->setSize(QSize(w * ratio, h * ratio));
device->setDevicePixelRatio(ratio);
}

void QOpenGLWorkspaceWidget::initDeviceIfNeed() {
if (!device) {
device = new QOpenGLPaintDevice();
drawer->setPaintDevice(device);
}
}

void QOpenGLWorkspaceWidget::paintGL() {
initDeviceIfNeed();
glDisable(GL_DEPTH_TEST);
glClearColor(1, 1, 1, 1);
workspaceDrawer->draw();
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com