#include #include #include QComboBox* createCombobox() { const auto style = R"( QComboBox:open { border: 1px solid green; } QComboBox:closed { border: 1px solid red; } )"; const auto comboBox = new QComboBox(); comboBox->addItem(""); comboBox->setStyleSheet(style); return comboBox; } int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget w; w.resize(640, 480); w.setLayout(new QHBoxLayout); w.layout()->addWidget(createCombobox()); w.show(); return a.exec(); }