Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qoptionswidget_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QOPTIONSWIDGET_H
5#define QOPTIONSWIDGET_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the help generator tools. This header file may change from version
13// to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qhash.h>
19#include <QtWidgets/qwidget.h>
20
21QT_BEGIN_NAMESPACE
22
23class QListWidget;
24class QListWidgetItem;
25
26class QOptionsWidget : public QWidget
27{
29public:
30 QOptionsWidget(QWidget *parent = nullptr);
31
32 void clear() { setOptions({}, {}); }
33 void setOptions(const QStringList &validOptions, const QStringList &selectedOptions);
34 QStringList validOptions() const { return m_validOptions; }
35 QStringList selectedOptions() const { return m_selectedOptions; }
36
37 void setNoOptionText(const QString &text);
38 void setInvalidOptionText(const QString &text);
39
42
43private:
44 QString optionText(const QString &optionName, bool valid) const;
45 QListWidgetItem *appendItem(const QString &optionName, bool valid, bool selected);
46 void appendSeparator();
47 void itemChanged(QListWidgetItem *item);
48
49 QListWidget *m_listWidget = nullptr;
50 QString m_noOptionText;
51 QString m_invalidOptionText;
52 QStringList m_validOptions;
53 QStringList m_invalidOptions;
54 QStringList m_selectedOptions;
55 QHash<QString, QListWidgetItem *> m_optionToItem;
56 QHash<QListWidgetItem *, QString> m_itemToOption;
57};
58
59QT_END_NAMESPACE
60
61#endif // QOPTIONSWIDGET_H
static void setSeparator(QListWidgetItem *item)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
This pure abstract function must be reimplemented if you want to provide custom rendering.
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
This pure abstract function must be reimplemented if you want to provide custom rendering.
ListWidgetDelegate(QWidget *w)
static bool isSeparator(const QModelIndex &index)
void setInvalidOptionText(const QString &text)
QStringList validOptions() const
void setOptions(const QStringList &validOptions, const QStringList &selectedOptions)
QStringList selectedOptions() const
void setNoOptionText(const QString &text)
static QStringList subtract(const QStringList &minuend, const QStringList &subtrahend)