- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的 Qt 应用程序中绘制线和点,但在 QPainter 中似乎存在缩放错误时遇到了问题。我的线条工作得很好,但点会受到某些缩放转换的影响,尽管笔被设置为“化妆品”。最让我困扰的是似乎只有一个轴(x 轴)受到影响。否则我可以将其归结为转换/矩阵代码中的一些浮点精度问题。
Qt 版本:Qt 4.8 for embedded、Qt 5.4 for Desktop、Qt 5.6 LTS for Desktop
这里有一些效果图,实际上看起来应该都一样(比如最左边的那个):
我有一个从 QWidget 派生的 RenderArea,它只是绘制上面的图像之一。 RenderArea 只是在 main() 中实例化并显示。那里的代码很简单,所以这里是相关的绘画代码:
void RenderArea::paintEvent(QPaintEvent* /* event */)
{
const qreal scaleFactor = 0.01;
// Define a "unit" square
std::vector<QPointF> points;
points.push_back(QPointF(0, 0));
points.push_back(QPointF(1.0, 0));
points.push_back(QPointF(1.0, 1.0));
points.push_back(QPointF(0, 1.0));
// Build a scaled version of the points
for (unsigned i = 0; i < points.size(); i++) {
points[i] *= scaleFactor;
}
QPainter painter(this);
painter.save();
// Scale the painter so that every square takes 100 pixels
// in screen space regardless of the scaleFactor:
painter.scale(100.0 / scaleFactor, 100.0 / scaleFactor);
QPen pointPen(Qt::blue, 10);
pointPen.setCosmetic(true);
painter.setPen(pointPen);
painter.drawPoints(points.data(), points.size());
QPen linePen(Qt::red, 5);
linePen.setCosmetic(true);
painter.setPen(linePen);
painter.drawPolyline(points.data(), points.size());
painter.restore();
}
该示例基于 Qt 附带的 basicdrawing 示例,但我剥离了所有内容以突出问题。
最佳答案
为了结束这个主题,我想添加对另一个 stackoverflow 问题的引用: Why does QPainter::drawPoint draw a horizontal line segment?
这似乎是 Qt 中的一个错误,已在此处提交: QPainter::drawPoints draws line segments instead of points
正如评论中所指出的,可以通过编写自己的绘制点代码、修补 Qt、绘制图像而不是点或使用 drawEllipse 来克服此错误。
关于c++ - 为什么 QPainter 在一个轴上缩放(修饰)点,尽管它们不应该受到影响?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52181274/
我在使用 lambda 表达式时遇到问题,该表达式用于自定义过滤来自 DataGridView 的数据。 这是表达式: private static Expression> ExpressionLon
我想使用装饰器模式扩展 basic_streambuf 对象的行为。这就是我目前得到的: template class forwarding_basic_streambuf : boost::
我正在编写一个 Backbone 应用程序,我想编写一个经过身份验证的装饰器,我可以用它来装饰路由器类中的方法(路由)列表。 所以我有一个带有几种方法的路由器,并尝试过类似的方法。但是,当我调用我想要
我想重写 alert() Javascript 函数,同时保留它的“聚焦”行为。即,自定义方面,同时将焦点带到打开弹出窗口的浏览器选项卡。 最佳答案 无法直接自定义/装饰 JavaScript 警报框
我们如何在 jquery mobile 中实现事件行为内部的 touch up。 我希望它的行为与 native ios 按钮完全相同。我们可以点击并按住点击并在按钮内移动手指只有当我在按钮内释放时才
我正在尝试覆盖模块(connect-mongo)中的类。该模块的工作原理大致如下: 在server.js中: const session = require('express-session'); c
我希望使用托管代码在非托管 C++ DLL 上加载库,然后在已损坏的外部函数上调用 GetProcAddress。我的问题是,您从 C++ 编译器获得的错位名称是否具有确定性?即:如果原始签名未更改,
为什么我不能使用 @staticmethod 装饰器使类的 __call__ 方法静态化? class Foo(object): @staticmethod def bar():
我有一个小的 Delphi 10.3.3 应用程序,它有一些文本编辑功能,使用用户输入文本的 TMemo。 我正在尝试包含一些格式选项,如本网站提供的内容: http://qaz.wtf/u/conv
这是我关于使用 Swift 运行的 iOS 应用程序的情况。 我有一个下载按钮,触摸后即可开始下载文件: @IBAction func downloadButtonPressed() { if
我有一个 View ,我需要检测一个属性是否用隐藏输入装饰。 我的属性(property)被定义为: [HiddenInput(DisplayValue = false)] public string
我在我的 Qt 应用程序中绘制线和点,但在 QPainter 中似乎存在缩放错误时遇到了问题。我的线条工作得很好,但点会受到某些缩放转换的影响,尽管笔被设置为“化妆品”。最让我困扰的是似乎只有一个轴(
我在 Eclipse 中遇到 Java 语法着色问题。我正在尝试更改 Eclipse 中 JUST java 修饰符的文本颜色(如公共(public)、 protected 、私有(private))
我在站点上有一些限制区域,我想为其指定 login_required 装饰器。但是我想在主 urls.py 中每次包含一次,而不是包含 urls.py 中的每个单独的 url 所以代替: /priva
这个建议似乎很有意义,因为该方法中没有使用 self,但现在我很好奇: 这是对 CBV 的疏忽吗?用户应该手动装饰每个 @staticmethod? Django 中是否已经有一些代码可以自动使所有
python 3.3:我可以装饰一个函数来忽略所有与命名参数不匹配的位置参数吗? import functools def ignore_star_args(): def wrapper(fu
我是一名优秀的程序员,十分优秀!