Linux QT4.8 drawLine drawText设置
QPen pen(QColor(100, 100, 100));
pPainter->setPen(pen);
pPainter->drawLine(m_leftMagicHint, 5, m_leftMagicHint, height()-m_bottomMagicHint+5);
pPainter->drawLine(m_leftMagicHint, height()-m_bottomMagicHint, width(), height()-m_bottomMagicHint);
pen.setStyle(Qt::DotLine);
pPainter->setPen(pen);
设置线型:
pen.setStyle(Qt::DotLine);
设置线宽
QPen pen(QColor(100, 100, 100));
pen.setWidth(10);
设置线条颜色:
pen.setColor(QColor(100,100,100));
写文字:
pen.setColor(QColor(255,255,255));
pPainter->setPen(pen);
pPainter->drawText( QRectF(startX, startY + 4, 70, 30), Qt::AlignCenter|Qt::TextWordWrap,
firstDate.addMSecs(dateStepMsec*i).toString("yyyy-MM-dd HH:mm:ss") );
除此之外,还可以直接这样设置线型颜色:
QPainter *pPainter;
pPainter->setPen(QColor(0,0,255));