You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Include/iBase/iPlugin/ZxComboBoxFuzzy.h

88 lines
2.6 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include <QComboBox>
#include "Defines.h"
#include "iPlugin_global.h"
// 方案二:
// 自定义Combobox支持CheckBox、Radio双重选
// 作者:地大学生 wangjr
class I_PLUGIN_EXPORT ZxComboBoxFuzzy : public QComboBox
{
Q_OBJECT
public:
explicit ZxComboBoxFuzzy(QWidget* parent = 0);
~ZxComboBoxFuzzy();
void setInfos(QStringList& listAllItems, \
QStringList listCbxs = QStringList(), \
QString sRadio = "");
/// @brief 参数传递,确定默认值
/// @param listAllItems 所有数据项
/// @param vecIndexCbxs 复选项索引,默认为空
/// @param indexRadio 单选项索引,默认为-1
/// @note 如果indexRadio为-1且vecIndexCbxs非空
/// 则指定indexRadio为vecIndexCbxs第一个
void setInfos(const QStringList& listAllItems, \
QVector<int> vecIndexCbxs = VecInt(), \
int indexRadio = -1);
private:
void init();
void saveInitialState();// 保存初始状态
void updateComboBoxDisplay();
signals:
// 当选择变化时发射,传递复选框选中的索引和单选框的索引
void sigSelChanged(const QVector<int>& vecIndexCbx, int indexRadio);
// void accepted();
// void rejected();
private slots:
void slotCheckBoxStateChanged(int state);// 复选框状态变化槽函数
void slotRadioBtnToggled(bool checked);// 单选按钮状态变化槽函数
void slotOkClicked();// 确认按钮点击槽函数
void slotCancelClicked();// 取消按钮点击槽函数
protected:
void showPopup();
void hidePopup();
private:
QListWidget* m_pListWx; // 列表小部件指针,用于显示列表项
QFrame* m_pPopupFrame; // 弹出框架
QPushButton* m_pOkBtn; // 确认按钮
QPushButton* m_pCancelBtn; // 取消按钮
int m_nRadioIndex; // 单选按钮索引
QVector<int> m_vecCheckedIndices; // 复选框选中的索引
QVector<int> m_vecInitialCheckedIndices; // 初始状态时复选框选中的索引
int m_nInitialRadioIndex; // 初始状态时单选按钮的索引
QStringList m_listAllItems; // 所有选项内容
};
//class MainWindow : public QMainWindow {
// Q_OBJECT
//public:
// explicit MainWindow(QWidget* parent = 0);
//private slots:
// void slotSelectionChanged(const QVector<int> &vecIndexCbx, int indexRadio);//响应CustomComboBox的sigSelChanged信号
// void slotAccepted();// 响应CustomComboBox的accepted信号
// void slotRejected();//响应CustomComboBox的rejected信号
//};