#include "selectwelldialog.h" #include "ui_selectwelldialog.h" #include #include int g_SelectWellIndex = 0; SelectWellDialog::SelectWellDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SelectWellDialog) { ui->setupUi(this); loadStyle(":/qrc/qss/flatgray.css"); // connect(ui->ok, SIGNAL(clicked()), this, SLOT(slotOkClicked())); connect(ui->cancel, SIGNAL(clicked()), this, SLOT(slotCancelClicked())); } SelectWellDialog::~SelectWellDialog() { delete ui; } void SelectWellDialog::loadStyle(const QString &qssFile) { //加载样式表 QString qss; QFile file(qssFile); if (file.open(QFile::ReadOnly)) { //用QTextStream读取样式文件不用区分文件编码 带bom也行 QStringList list; QTextStream in(&file); //in.setCodec("utf-8"); while (!in.atEnd()) { QString line; in >> line; list << line; } file.close(); qss = list.join("\n"); QString paletteColor = qss.mid(20, 7); this->setPalette(QPalette(paletteColor)); //用时主要在下面这句 this->setStyleSheet(qss); } } void SelectWellDialog::setInfo(QStringList listWell, QStringList listSlf) { for(int i=0; icomboBox->addItem(listWell[i]); } } // void SelectWellDialog::slotOkClicked() { g_SelectWellIndex = ui->comboBox->currentIndex(); //关闭 accept(); // 让 QDialog::exec() 返回 QDialog::Accepted //QDialog::close(); } // void SelectWellDialog::slotCancelClicked() { reject(); // 让 QDialog::exec() 返回 QDialog::Rejected //QDialog::close(); }