mainwindow.h
void comboBox_penStyle_changed(int);
mainwindow.cpp
QComboBox *comboBox_penStyle = new QComboBox;
SL_penStyle << "______" << "----------" << ".........." << "-.-.-.-.-." << "-..-..-..-.." << "CustomDashLine";
comboBox_penStyle->addItems(SL_penStyle);
ui->mainToolBar->addWidget(comboBox_penStyle);
connect(comboBox_penStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(comboBox_penStyle_changed(int)));
void MainWindow::comboBox_penStyle_changed(int index)
Qt::PenStyle ps = static_cast(index + 1);
imageWidget->pen.setStyle(ps);
CustomDashLine还没做