31 Q_DISABLE_COPY(QWinRegistryKey)
35 QWinRegistryKey(QObject *parent =
nullptr);
36 explicit QWinRegistryKey(HKEY parentHandle,
const wchar_t *subKey,
37 REGSAM permissions = KEY_READ, REGSAM access = 0,
38 QObject *parent =
nullptr);
39 explicit QWinRegistryKey(HKEY parentHandle,
const QString &subKey,
40 REGSAM permissions = KEY_READ, REGSAM access = 0,
41 QObject *parent =
nullptr);
44 QWinRegistryKey(QWinRegistryKey &&other)
noexcept
47 void operator=(QWinRegistryKey &&) =
delete;
49 : m_key(std::exchange(other.m_key,
nullptr)) {}
50 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QWinRegistryKey)
51 void swap(QWinRegistryKey &other)
noexcept
53 qt_ptr_swap(m_key, other.m_key);
57 [[nodiscard]]
bool isValid()
const {
return m_key !=
nullptr; }
59 [[nodiscard]] HKEY handle()
const {
return m_key; }
61 operator HKEY()
const {
return handle(); }
67 [[nodiscard]] QVariant value(
const wchar_t *subKey)
const;
68 [[nodiscard]] QVariant value(
const QString &subKey)
const;
71 [[nodiscard]] std::optional<T> value(
const wchar_t *subKey)
const
73 return to_optional<T>(value(subKey));
77 [[nodiscard]] std::optional<T> value(
const QString &subKey)
const
79 return to_optional<T>(value(subKey));
82 QString stringValue(
const wchar_t *subKey)
const;
83 QString stringValue(
const QString &subKey)
const;
85#ifndef QT_NO_DEBUG_STREAM
86 friend Q_CORE_EXPORT QDebug operator<<(QDebug dbg,
const QWinRegistryKey &);
93 void connectNotify(
const QMetaMethod &signal) override;
97 static std::optional<T> to_optional(QVariant v)
100 return qvariant_cast<T>(std::move(v));
104 HKEY m_key =
nullptr;
105 QUniqueWin32NullHandle m_keyChangedEvent;