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// Qt-Security score:significant reason:default
4
5#ifndef QOPTIONSWIDGET_H
6#define QOPTIONSWIDGET_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of the help generator tools. This header file may change from version
14// to version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qhash.h>
20#include <QtWidgets/qwidget.h>
21
22QT_BEGIN_NAMESPACE
23
24class QListWidget;
25class QListWidgetItem;
26
27class QOptionsWidget : public QWidget
28{
30public:
31 QOptionsWidget(QWidget *parent = nullptr);
32
33 void clear() { setOptions({}, {}); }
34 void setOptions(const QStringList &validOptions, const QStringList &selectedOptions);
35 QStringList validOptions() const { return m_validOptions; }
36 QStringList selectedOptions() const { return m_selectedOptions; }
37
38 void setNoOptionText(const QString &text);
39 void setInvalidOptionText(const QString &text);
40
43
44private:
45 QString optionText(const QString &optionName, bool valid) const;
46 QListWidgetItem *appendItem(const QString &optionName, bool valid, bool selected);
47 void appendSeparator();
48 void itemChanged(QListWidgetItem *item);
49
50 QListWidget *m_listWidget = nullptr;
51 QString m_noOptionText;
52 QString m_invalidOptionText;
53 QStringList m_validOptions;
54 QStringList m_invalidOptions;
55 QStringList m_selectedOptions;
56 QHash<QString, QListWidgetItem *> m_optionToItem;
57 QHash<QListWidgetItem *, QString> m_itemToOption;
58};
59
60QT_END_NAMESPACE
61
62#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)
Combined button and popup list for selecting options.
static QStringList subtract(const QStringList &minuend, const QStringList &subtrahend)