123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #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 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:
- int m_nMargin;
- QList<ItemData> m_items;
- bool m_autoquery;
- bool m_showPopup;
- QString m_currentText;
- };
- #endif // SEARCHCOMBOBOX_H
|