MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / applyComboBoxStyling

Function applyComboBoxStyling

pj_widgets/src/ComboBox.cpp:15–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace PJ {
14
15void applyComboBoxStyling(QComboBox* combo) {
16 if (combo == nullptr) {
17 return;
18 }
19 combo->setItemDelegate(new ComboBoxGradientDelegate(combo));
20 // QAbstractItemView inherits QFrame; without this, Qt's style paints
21 // its own 1-px frame around the view ON TOP of the QSS border, giving
22 // a double-line at the popup's edges. Killing the QFrame frame leaves
23 // only the QSS border + border-radius visible.
24 combo->view()->setFrameShape(QFrame::NoFrame);
25
26 // Popup container (QComboBoxPrivateContainer): make it ARGB so QSS
27 // border-radius clips corners to alpha=0; kill its frame; zero
28 // margins so the inner view fills it exactly; suppress WM shadow.
29 if (auto* popup_window = combo->view()->window()) {
30 popup_window->setAttribute(Qt::WA_TranslucentBackground, true);
31 popup_window->setWindowFlag(Qt::NoDropShadowWindowHint, true);
32 if (auto* frame = qobject_cast<QFrame*>(popup_window)) {
33 frame->setFrameShape(QFrame::NoFrame);
34 }
35 popup_window->setContentsMargins(0, 0, 0, 0);
36 if (auto* lay = popup_window->layout()) {
37 lay->setContentsMargins(0, 0, 0, 0);
38 lay->setSpacing(0);
39 }
40 }
41}
42
43ComboBox::ComboBox(QWidget* parent) : QComboBox(parent) {
44 applyComboBoxStyling(this);

Callers 2

ComboBoxMethod · 0.85
adaptComboBoxesFunction · 0.85

Calls 3

setFrameShapeMethod · 0.80
setAttributeMethod · 0.45
setSpacingMethod · 0.45

Tested by

no test coverage detected