MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / ElaComboBox

Method ElaComboBox

ElaWidgetTools/ElaComboBox.cpp:15–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include <QPropertyAnimation>
14Q_PROPERTY_CREATE_Q_CPP(ElaComboBox, int, BorderRadius)
15ElaComboBox::ElaComboBox(QWidget* parent)
16 : QComboBox(parent), d_ptr(new ElaComboBoxPrivate())
17{
18 Q_D(ElaComboBox);
19 d->q_ptr = this;
20 d->_pBorderRadius = 3;
21 d->_themeMode = eTheme->getThemeMode();
22 setObjectName("ElaComboBox");
23 setFixedHeight(35);
24 d->_comboBoxStyle = new ElaComboBoxStyle(style());
25 setStyle(d->_comboBoxStyle);
26
27 //调用view 让container初始化
28 setView(new QListView(this));
29 QAbstractItemView* comboBoxView = this->view();
30 comboBoxView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
31 ElaScrollBar* scrollBar = new ElaScrollBar(this);
32 comboBoxView->setVerticalScrollBar(scrollBar);
33 ElaScrollBar* floatVScrollBar = new ElaScrollBar(scrollBar, comboBoxView);
34 floatVScrollBar->setIsAnimation(true);
35 comboBoxView->setAutoScroll(false);
36 comboBoxView->setSelectionMode(QAbstractItemView::NoSelection);
37 comboBoxView->setObjectName("ElaComboBoxView");
38 comboBoxView->setStyleSheet("#ElaComboBoxView{background-color:transparent;}");
39 comboBoxView->setStyle(d->_comboBoxStyle);
40 QWidget* container = this->findChild<QFrame*>();
41 if (container)
42 {
43 container->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
44 container->setAttribute(Qt::WA_TranslucentBackground);
45 container->setObjectName("ElaComboBoxContainer");
46 container->setStyle(d->_comboBoxStyle);
47 QLayout* layout = container->layout();
48 while (layout->count())
49 {
50 layout->takeAt(0);
51 }
52 layout->addWidget(view());
53 layout->setContentsMargins(6, 0, 6, 6);
54#ifndef Q_OS_WIN
55#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
56 container->setStyleSheet("background-color:transparent;");
57#endif
58#endif
59 }
60 QComboBox::setMaxVisibleItems(5);
61 connect(eTheme, &ElaTheme::themeModeChanged, d, &ElaComboBoxPrivate::onThemeChanged);
62}
63
64ElaComboBox::~ElaComboBox()
65{

Callers

nothing calls this directly

Calls 5

getThemeModeMethod · 0.80
countMethod · 0.80
takeAtMethod · 0.80
addWidgetMethod · 0.80
setIsAnimationMethod · 0.45

Tested by

no test coverage detected