20 #include <QPaintEvent> 37 for (
int style = Qt::SolidLine; style < Qt::CustomDashLine; ++style)
52 setCurrentIndex(style-Qt::SolidLine);
56 return static_cast<Qt::PenStyle
>(Qt::SolidLine+currentIndex());
64 QComboBox::paintEvent(event);
66 QVariant data = itemData(currentIndex(), Qt::UserRole);
69 QPainter painter(
this);
72 pen.setColor(palette().color(QPalette::Text));
74 pen.setStyle(static_cast<Qt::PenStyle>(data.toInt()));
77 painter.drawLine(event->rect().left()+5,
event->rect().center().y(),
78 event->rect().right()-20,
event->rect().center().y());
PenStyleComboBox(QWidget *parent=0)
Qt::PenStyle getCurrentStyle() const
virtual ~PenStyleComboBox()
void setCurrentStyle(Qt::PenStyle style)
void currentStyleChanged(int style)
void paintEvent(QPaintEvent *event)
void currentIndexChanged(int index)