本文通过利用QCoomboBox,QCheckBox,QListwidget实现下拉复选框。
widget.h文件内容
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QListWidget>
#include <QListWidgetItem>
#include <QCheckBox>
#include <QLabel>
#include <QVBoxLayout>
#include <QComboBox>
#include <list>
#include <map>
QT_BEGIN_NAMESPACE
namespace Ui {
class Widget; }
QT_END_NAMESPACE
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
QVBoxLayout* vboxLayout = new QVBoxLayout;
QLabel* selectedBox = new QLabel(tr("show selected Items"));
QComboBox* useTablesComboBox = new QComboBox;
std::list<std::string> allcheckboxString;
QListWidget* alltablesListWidget = nullptr;
std::map<unsigned int,QCheckBox*> allTablesCheckBox;
std::map<unsigned int,std::string> selectedTabels;
void initi