Qt SetRenderHints问题

发布于 2024-10-12 04:43:27 字数 211 浏览 6 评论 0原文

我使用 Qt 4.6.3,但遇到问题。

ui.graphicsView->setRenderHints(QPainter::Antialiasing,false);

但有些线条颜色会改变。我能做些什么?请帮我。

我想我无法表达自己。我有很多行。当我使用此代码相同的行颜色变化(行顶部比行底部浅)时,我无法解决这个问题。

I use Qt 4.6.3 and I have a problem.

ui.graphicsView->setRenderHints(QPainter::Antialiasing,false);

but some lines colors changes. what can I do? Please help me.

I think that I cant express myself. I hava a lot of line. When I use this code same line color changes( top of line lighter than bottom of line ) I can t solve this problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

攒一口袋星星 2024-10-19 04:43:27

QPainter:: 抗锯齿、假值对于获得更好质量的绘画是必要的。

确定你的问题在于当你绘制线条时,无论何时使用画家都必须保存并恢复状态。

void Line:: paint (QPainter * painter, const QStyleOptionGraphicsItem * option,
QWidget * widget)
{
painter-> save (); / / save
painter-> setRenderHint (QPainter:: Antialiasing);
painter-> setPen (mypen);
painter-> drawLine (...);
painter-> restore (); / / restore
}

当你在Painter中进行更改时,如果不调用save()和restore()方法,它可能会变得不稳定。祝你好运

QPainter:: Antialiasing, false is necessary to achieve a better quality paint.

sure your problem is in when you paint the lines, whenever you use the painter must save and restore the state.

void Line:: paint (QPainter * painter, const QStyleOptionGraphicsItem * option,
QWidget * widget)
{
painter-> save (); / / save
painter-> setRenderHint (QPainter:: Antialiasing);
painter-> setPen (mypen);
painter-> drawLine (...);
painter-> restore (); / / restore
}

when you make changes in Painter, it could become unstable if not call the methods save() and restore (). good luck

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文