当前位置: 代码迷 >> QT开发 >> qt中的drawline函数怎的把线加粗
  详细解决方案

qt中的drawline函数怎的把线加粗

热度:87   发布时间:2016-04-25 04:41:52.0
qt中的drawline函数怎样把线加粗?
如题。。。求高手。。。

------解决方案--------------------
当然是设置QPen的参数
C/C++ code
    QPainter painter(this);    QLineF line(10.0, 80.0, 90.0, 20.0);    painter.setPen(QPen(Qt::blue, 2/*this param Sets the pen width to the given width in pixels with integer precision.*/));    painter.drawLine(line);
------解决方案--------------------
C/C++ code
painter->setPen(QPen(QBrush(Qt::darkGray), 2, Qt::SolidLine));//其中的第2个参数 2 对应线宽
------解决方案--------------------
Qpen里的setWidth函数。

void QPen::setWidth ( int width )
Sets the pen width to the given width in pixels with integer precision.
A line width of zero indicates a cosmetic pen. This means that the pen width is always drawn one pixel wide, independent of the transformation set on the painter.
Setting a pen width with a negative value is not supported.
  相关解决方案