介绍

选择框,通过提供一组字符串,通过单选或者多选后,返回选择的结果。
列表支持双击快速确定,按住Shift点击连续范围选择,按住Ctrl跳跃范围选择。

使用

▼引入头文件

  1. #include "VChooseBox.h"

▼函数

  1. // 单项选择
  2. static QString getChooseItem(QWidget *parent, const QString &title, const QStringList &itemList, bool custom = false);
  3. //多项选择
  4. static QStringList getChooseItems(QWidget *parent, const QString &title, const QStringList &itemList);

▼实例:

  1. QStringList list1, list2;
  2. list1 << "郭麒麟" << "岳云鹏" << "于谦" << "栾云平";
  3. // 根据提供的内容选择
  4. QString result = VChooseBox::getChooseItem(this, "请选择郭德纲的搭档", list1);
  5. // 根据提供的内容选择 + 自定义输入
  6. QString result = VChooseBox::getChooseItem(this, "请选择郭德纲的搭档", list1, true);
  7. qDebug() << "单选结果:" << result;
  8. list2 << "打游戏" << "吸烟" << "喝酒" << "喝可乐"<< "看两三个人演完的电影" << "烫头";
  9. QStringList listResult = VChooseBox::getChooseItems(this, "请选择于谦的三大爱好", list2);
  10. qDebug() << "多选结果:" << listResult;

▼演示:
选择框测试.gif
输入自定义类型
image.png