Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
正如标题所说,我正在将像素图绘制到特定位置的场景上。QT 通过将像素图的左上角放置在我指定的点来绘制像素图。但是,我希望将像素图的中心放置在这一点上。(像素图是十字准线)。有谁知道如何做到这一点?提前致谢
将指定点平移像素图宽度的一半到左侧,将像素图高度的一半平移到顶部,然后将像素图绘制到该点。只是一些数学。:)
void QPainter::translate ( const QPointF & offset )
通过给定的偏移量平移坐标系;即给定的偏移量被添加到点。
painter.translate(specific_location); painter.drawPixmap(-pixmap.rect().center(), pixmap);