1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #ifndef SEARCHCOMBOBOX_H
- #define SEARCHCOMBOBOX_H
- #include <QComboBox>
- #include <QMouseEvent>
- class SearchComboBox : public QComboBox
- {
- Q_OBJECT
- public:
- typedef struct ItemData
- {
- QString text;
- QVariant userdata;
- QString alphbat;
- }ItemData;
- public:
- explicit SearchComboBox(QWidget *parent = nullptr);
- ~SearchComboBox();
-
- void showPopup() override;
- void hidePopup() override;
-
- void setViewShadowEffect();
- void clear();
- void addItem(const QString &text, const QVariant &userData = QVariant());
- void autoquery();
- protected:
- bool event(QEvent *event) override;
- void wheelEvent(QWheelEvent *e) override;
- private slots:
- void OnCurrentIndexChanged(const QString &text);
- private:
- const int LISTVIEW_MARGIN = 12;
- QList<ItemData> m_items;
- bool m_autoquery;
- bool m_showPopup;
- QString m_currentText;
- };
- #endif
|