一.效果
1.点击下拉列表的复选框区域
2.点击下拉列表的非复选框区域
二.实现
QHCustomComboBox.h
#ifndef QHCUSTOMCOMBOBOX_H
#define QHCUSTOMCOMBOBOX_H
#include <QLineEdit>
#include <QListWidget>
#include <QCheckBox>
#include <QComboBox>
#include <QEvent>
#include <QKeyEvent>
#include <QWheelEvent>
class QHCustomComboBox: public QComboBox
{
Q_OBJECT
public:
explicit QHCustomComboBox(QWidget* parent = nullptr);
void addItem(const QString &text, const QVariant &variant = QVariant());
void addItems(const QStringList &texts);
QStringList currentText();
int count() const;
void setPlaceHolderText(const QString