QComboBox FramelessWindowHint not work on MacOS
Unsolved
General and Desktop
-
Hello,
I built a QT application on macOS Big Sur, and my QT version is 6.2.0.
When I built a custom QComboBox, the drop-list always had a shadow black frame behind it.
I tried to set flags below, but it still not work on Mac system. (But it works on Windows system)comboBox->view()->window()->setWindowFlags( Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint); comboBox->view()->window()->setAttribute(Qt::WA_TranslucentBackground);
detail code:
comboBox->setStyleSheet("QComboBox {" "combobox-popup: 0;" "background: transparent;" "border:2px solid red;" "border-radius: 10px;" "padding-left: 5px;" "background-color: white;" "font: bold;" "font-size: 16px;" "color: rgb(107,107,107);}" "QComboBox::down-arrow{" "image: url(:/resources/icons-chevron-text-down.png);" "background-color: white;}" "QComboBox::drop-down{" "border:none;" "subcontrol-position: top right;" "subcontrol-origin: padding;" "width:40px;}" "QScrollBar:vertical {" "border: 1px transparent rgb(213, 218, 223);" "background:rgb(213, 218, 223);" "border-radius: 2px;" "width:6px;" "margin: 2px 0px 2px 1px;}" "QScrollBar::handle:vertical {" "border-radius: 2px;" "min-height: 0px;" "background-color: rgb(131, 131, 131);}" "QScrollBar::add-line:vertical {" "height: 0px;" "subcontrol-position: bottom;" "subcontrol-origin: margin;}" "QScrollBar::sub-line:vertical {" "height: 0px;" "subcontrol-position: top;" "subcontrol-origin: margin;}"); QListView *view = new QListView(comboBox); view->setStyleSheet("QListView{top: 2px;" "border:1px solid red;" "border-radius: 8px;" "background-color: white;" "show-decoration-selected: 1;" "padding-left: 5px;" "padding-right: 6px;" "padding-top: 6px;" "padding-bottom: 2px;" "font: bold;" "font-size: 16px;}" "QListView::item{" "height: 30px;" "background-color: white;" "color: rgb(107,107,107);}" "QListView::item:hover{" "background-color: green;" "color: white;}"); view->setCursor(Qt::PointingHandCursor); comboBox->setView(view); comboBox->setMaxVisibleItems(5); comboBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); comboBox->setFixedSize(500,45); comboBox->view()->window()->setWindowFlags( Qt::Popup | Qt::FramelessWindowHint |Qt::NoDropShadowWindowHint); comboBox->view()->window()->setAttribute(Qt::WA_TranslucentBackground);