本人做了一个自定义控件SeepedSearch 用于快速检索匹配的字符的下拉框 方便查找目标
直接上源码
1.
SpeedSerach.h
#pragma once
#include
class QComboBox;
class QCompleter;
class SpeedSearch : public QWidget
{
Q_OBJECT
public:
explicit SpeedSearch(QWidget *parent = 0);
void initData(const QStringList &strList);
void setEditable(bool bEnabled);
void setCurrentText(const QString& sText);
QString currentText();
void setCurrentIndex(const int& nIdx);
int currentIndex();
void AddItem(const QString& sText);
int Count();
QString itemText(int idx);
void hideSubcontrol();//掩藏下拉框
void setPlaceholderText(QString& sText);
public slots:
void slotCurrentIndexChanged(const QString &str);
signals:
void currentIndexChanged(const QString&);
protected:
void showEvent(QShowEvent *event);
private:
QCo