【问题标题】:how to make boundary line have also a border of black color using Qpainter如何使用Qpainter使边界线也有黑色边框
【发布时间】:2017-01-10 07:32:20
【问题描述】:

我正在使用 Qt。我使用QPainter 来制作边界线。但我希望边界线也有一个 1 像素宽的边框,以便更明显。

下图显示了带有黑色边框的黄色边框。 此图像是逻辑的参考。我将它应用在随机形状上

【问题讨论】:

  • 欢迎来到 Stack Overflow!为了给您一个很好的答案,如果您还没有看过How to Ask,它可能会对我们有所帮助。如果您可以提供minimal reproducible example,它可能也很有用。

标签: qt qpainter


【解决方案1】:

从您的边界框创建一个较小的矩形。

QRect adjusted(int dx1, int dy1, int dx2, int dy2) const

QRect smallerbox = boundingRect().adjusted(boundingRect.topLeft().x() +1, boundingRect.topLeft().y() +1, boundingRect.bottomRight().x() -1, boundingRect.bottomRight().y() -1);

【讨论】:

  • 我想申请随机形状的物品
猜你喜欢
  • 2015-09-17
  • 1970-01-01
  • 1970-01-01
  • 2018-11-16
  • 2014-07-09
  • 1970-01-01
  • 1970-01-01
  • 2014-12-02
  • 1970-01-01
相关资源
最近更新 更多