| 185 | } |
| 186 | |
| 187 | void CCheckBoxHeader::DrawText(QPainter* painter, const QRect& rect, |
| 188 | const QString& text, Qt::Alignment alignment) const |
| 189 | { |
| 190 | if (text.isEmpty()) return; |
| 191 | |
| 192 | painter->save(); |
| 193 | |
| 194 | // 文本省略处理 |
| 195 | QFontMetrics fm = painter->fontMetrics(); |
| 196 | QString elided = fm.elidedText(text, Qt::ElideRight, rect.width()); |
| 197 | |
| 198 | QPalette palette = this->palette(); |
| 199 | painter->setPen(palette.color(QPalette::Text)); |
| 200 | |
| 201 | // 绘制文本 |
| 202 | painter->drawText(rect, alignment, elided); |
| 203 | |
| 204 | painter->restore(); |
| 205 | } |
| 206 | |
| 207 | void CCheckBoxHeader::mousePressEvent(QMouseEvent *event) |
| 208 | { |