//![1] Begins
drawConfigBar->setOrientation(Qt::Vertical);
drawConfigBar->setMovable(true);
drawConfigBar->setFloatable(true);
//![2]
//Pen Style
newComboBox->setToolTip(newComboBox->tr("Line style"));
newComboBox->setEditable(false);
newComboBox
->setIconSize
(QSize(80,
14));
newComboBox->setMinimumWidth(80);
connect(newComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(slotLineStyleSelected(int)));
for (aaa = Qt::SolidLine; aaa < Qt::CustomDashLine; aaa++)
{
pix.fill(Qt::white);
QPen pen
(brush,
2.5,
(Qt
::PenStyle)aaa
);
painter.setPen(pen);
painter.drawLine(2,7,78,7);
newComboBox
->addItem
(QIcon(pix
),
"");
}
newComboBox->setCurrentIndex((int)Qt::SolidLine - 1);
drawConfigBar->addWidget(newComboBox);
//Pen width
newComboBox->setToolTip(newComboBox->tr("Line width"));
newComboBox->setEditable(false);
newComboBox
->setIconSize
(QSize(80,
14));
newComboBox->setMinimumWidth(80);
connect(newComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(slotLineThicknessSelected(int)));
for (aaa = 1; aaa < 6; aaa++)
{
pix.fill(Qt::white);
QPen pen
(brush,
(double)aaa,Qt
::SolidLine);
painter.setPen(pen);
painter.drawLine(2,7,78,7);
newComboBox
->addItem
(QIcon(pix
),
"");
}
newComboBox->setCurrentIndex(0);
drawConfigBar->addWidget(newComboBox);
//![1] Begins
drawConfigBar = new QToolBar(QToolBar::tr("Draw Configuration Bar"),this);
drawConfigBar->setOrientation(Qt::Vertical);
drawConfigBar->setMovable(true);
drawConfigBar->setFloatable(true);
//![2]
QAction* newAction = NULL;
QComboBox* newComboBox = NULL;
//Pen Style
newComboBox = new QComboBox(drawConfigBar);
newComboBox->setToolTip(newComboBox->tr("Line style"));
newComboBox->setEditable(false);
newComboBox->setIconSize(QSize(80,14));
newComboBox->setMinimumWidth(80);
connect(newComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(slotLineStyleSelected(int)));
for (aaa = Qt::SolidLine; aaa < Qt::CustomDashLine; aaa++)
{
QPixmap pix(80,14);
pix.fill(Qt::white);
QBrush brush(Qt::black);
QPen pen(brush,2.5,(Qt::PenStyle)aaa);
QPainter painter(&pix);
painter.setPen(pen);
painter.drawLine(2,7,78,7);
newComboBox->addItem(QIcon(pix),"");
}
newComboBox->setCurrentIndex((int)Qt::SolidLine - 1);
drawConfigBar->addWidget(newComboBox);
//Pen width
newComboBox = new QComboBox(drawConfigBar);
newComboBox->setToolTip(newComboBox->tr("Line width"));
newComboBox->setEditable(false);
newComboBox->setIconSize(QSize(80,14));
newComboBox->setMinimumWidth(80);
connect(newComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(slotLineThicknessSelected(int)));
for (aaa = 1; aaa < 6; aaa++)
{
QPixmap pix(80,14);
pix.fill(Qt::white);
QBrush brush(Qt::black);
QPen pen(brush,(double)aaa,Qt::SolidLine);
QPainter painter(&pix);
painter.setPen(pen);
painter.drawLine(2,7,78,7);
newComboBox->addItem(QIcon(pix),"");
}
newComboBox->setCurrentIndex(0);
drawConfigBar->addWidget(newComboBox);
To copy to clipboard, switch view to plain text mode
Bookmarks