31 QWinRegistryKey() =
default;
32 explicit QWinRegistryKey(HKEY parentHandle,
const wchar_t *subKey,
33 REGSAM permissions = KEY_READ, REGSAM access = 0);
34 explicit QWinRegistryKey(HKEY parentHandle,
const QString &subKey,
35 REGSAM permissions = KEY_READ, REGSAM access = 0);
38 QWinRegistryKey(QWinRegistryKey &&other)
noexcept
39 : m_key(std::exchange(other.m_key,
nullptr)) {}
40 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QWinRegistryKey)
41 void swap(QWinRegistryKey &other)
noexcept
43 qt_ptr_swap(m_key, other.m_key);
46 [[nodiscard]]
bool isValid()
const {
return m_key !=
nullptr; }
48 [[nodiscard]] HKEY handle()
const {
return m_key; }
50 operator HKEY()
const {
return handle(); }
56 [[nodiscard]] QVariant value(
const wchar_t *subKey)
const;
57 [[nodiscard]] QVariant value(
const QString &subKey)
const;
60 [[nodiscard]] std::optional<T> value(
const wchar_t *subKey)
const
62 return to_optional<T>(value(subKey));
66 [[nodiscard]] std::optional<T> value(
const QString &subKey)
const
68 return to_optional<T>(value(subKey));
71 QString stringValue(
const wchar_t *subKey)
const;
72 QString stringValue(
const QString &subKey)
const;
74#ifndef QT_NO_DEBUG_STREAM
75 friend Q_CORE_EXPORT QDebug operator<<(QDebug dbg,
const QWinRegistryKey &);
80 static std::optional<T> to_optional(QVariant v)
83 return qvariant_cast<T>(std::move(v));
95 Q_DISABLE_COPY(QWinRegistryNotifier)
98 explicit QWinRegistryNotifier(QWinRegistryKey &&key, QObject *parent =
nullptr);
99 explicit QWinRegistryNotifier(HKEY parentHandle,
const wchar_t *subKey,
100 QObject *parent =
nullptr);
101 explicit QWinRegistryNotifier(HKEY parentHandle,
const QString &subKey,
102 QObject *parent =
nullptr);
104 [[nodiscard]]
bool isValid()
const {
return m_key.isValid(); }
105 [[nodiscard]]
const QWinRegistryKey &key()
const {
return m_key; }
111 QWinRegistryKey m_key;
112 QUniqueWin32NullHandle m_keyChangedEvent;