Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qobject.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QOBJECT_H
6#define QOBJECT_H
7
8#ifndef QT_NO_QOBJECT
9
10#include <QtCore/qobjectdefs.h>
11#include <QtCore/qstring.h>
12#include <QtCore/qbytearray.h>
13#include <QtCore/qlist.h>
14#ifdef QT_INCLUDE_COMPAT
15#include <QtCore/qcoreevent.h>
16#endif
17#include <QtCore/qscopedpointer.h>
18#include <QtCore/qmetatype.h>
19
20#include <QtCore/qobject_impl.h>
21#include <QtCore/qbindingstorage.h>
22#include <QtCore/qtcoreexports.h>
23
24#include <chrono>
25
27
28
29template <typename T> class QBindable;
30class QEvent;
31class QTimerEvent;
32class QChildEvent;
33struct QMetaObject;
34class QVariant;
35class QObjectPrivate;
36class QObject;
37class QThread;
38class QWidget;
39class QAccessibleWidget;
40#if QT_CONFIG(regularexpression)
42#endif
44
45typedef QList<QObject*> QObjectList;
46
47#if QT_CORE_REMOVED_SINCE(6, 7)
48Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString &name,
49 const QMetaObject &mo, QList<void *> *list, Qt::FindChildOptions options);
50#endif
51Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, QAnyStringView name,
52 const QMetaObject &mo, QList<void *> *list,
53 Qt::FindChildOptions options);
54#if QT_CORE_REMOVED_SINCE(6, 7)
55Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QMetaObject &mo,
56 QList<void *> *list, Qt::FindChildOptions options);
57#endif
58Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QRegularExpression &re,
59 const QMetaObject &mo, QList<void *> *list, Qt::FindChildOptions options);
60#if QT_CORE_REMOVED_SINCE(6, 7)
61Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo, Qt::FindChildOptions options);
62#endif
63Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, QAnyStringView name,
64 const QMetaObject &mo, Qt::FindChildOptions options);
65
66class Q_CORE_EXPORT QObjectData
67{
68 Q_DISABLE_COPY(QObjectData)
69public:
70 QObjectData() = default;
71 virtual ~QObjectData() = 0;
75
82 uint isWindow : 1; // for QWindow
85 uint willBeWidget : 1; // for handling widget-specific bits in QObject's ctor
86 uint wasWidget : 1; // for properly cleaning up in QObject's dtor
92
93 // ### Qt7: Make this return a const QMetaObject *. You should not mess with
94 // the metaobjects of existing objects.
95 QMetaObject *dynamicMetaObject() const;
96
97#ifdef QT_DEBUG
98 enum { CheckForParentChildLoopsWarnDepth = 4096 };
99#endif
100};
101
102class Q_CORE_EXPORT QObject
103{
105
106 Q_PROPERTY(QString objectName READ objectName WRITE setObjectName NOTIFY objectNameChanged
107 BINDABLE bindableObjectName)
108 Q_DECLARE_PRIVATE(QObject)
109
110public:
111 Q_INVOKABLE explicit QObject(QObject *parent = nullptr);
112 virtual ~QObject();
113
114 virtual bool event(QEvent *event);
115 virtual bool eventFilter(QObject *watched, QEvent *event);
116
117#if defined(QT_NO_TRANSLATION) || defined(Q_QDOC)
118 static QString tr(const char *sourceText, const char * = nullptr, int = -1)
119 { return QString::fromUtf8(sourceText); }
120#endif // QT_NO_TRANSLATION
121
122 QString objectName() const;
123#if QT_CORE_REMOVED_SINCE(6, 4)
124 void setObjectName(const QString &name);
125#endif
127 void setObjectName(const QString &name) { doSetObjectName(name); }
129 QBindable<QString> bindableObjectName();
130
131 inline bool isWidgetType() const { return d_ptr->isWidget; }
132 inline bool isWindowType() const { return d_ptr->isWindow; }
133 inline bool isQuickItemType() const { return d_ptr->isQuickItem; }
134
135 inline bool signalsBlocked() const noexcept { return d_ptr->blockSig; }
136 bool blockSignals(bool b) noexcept;
137
138 QThread *thread() const;
139#if QT_CORE_REMOVED_SINCE(6, 7)
140 void moveToThread(QThread *thread);
141#endif
143
144 int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer);
145
146#if QT_CORE_REMOVED_SINCE(6, 8)
147 int startTimer(std::chrono::milliseconds time, Qt::TimerType timerType = Qt::CoarseTimer);
148#endif
149 int startTimer(std::chrono::nanoseconds time, Qt::TimerType timerType = Qt::CoarseTimer);
150
151 void killTimer(int id);
152 void killTimer(Qt::TimerId id);
153
154 template<typename T>
155 T findChild(QAnyStringView aName, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
156 {
157 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
159 "No Q_OBJECT in the class passed to QObject::findChild");
160 return static_cast<T>(qt_qFindChild_helper(this, aName, ObjType::staticMetaObject, options));
161 }
162
163 template<typename T>
164 QList<T> findChildren(QAnyStringView aName, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
165 {
166 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
168 "No Q_OBJECT in the class passed to QObject::findChildren");
169 QList<T> list;
170 qt_qFindChildren_helper(this, aName, ObjType::staticMetaObject,
171 reinterpret_cast<QList<void *> *>(&list), options);
172 return list;
173 }
174
175 template<typename T>
176 T findChild(Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
177 {
178 return findChild<T>({}, options);
179 }
180
181 template<typename T>
182 QList<T> findChildren(Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
183 {
184 return findChildren<T>(QAnyStringView{}, options);
185 }
186
187#if QT_CONFIG(regularexpression)
188 template<typename T>
189 inline QList<T> findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
190 {
191 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
193 "No Q_OBJECT in the class passed to QObject::findChildren");
194 QList<T> list;
195 qt_qFindChildren_helper(this, re, ObjType::staticMetaObject,
196 reinterpret_cast<QList<void *> *>(&list), options);
197 return list;
198 }
199#endif // QT_CONFIG(regularexpression)
200
201 inline const QObjectList &children() const { return d_ptr->children; }
202
203 void setParent(QObject *parent);
204 void installEventFilter(QObject *filterObj);
205 void removeEventFilter(QObject *obj);
206
207 static QMetaObject::Connection connect(const QObject *sender, const char *signal,
208 const QObject *receiver, const char *member, Qt::ConnectionType = Qt::AutoConnection);
209
210 static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal,
211 const QObject *receiver, const QMetaMethod &method,
213
214 inline QMetaObject::Connection connect(const QObject *sender, const char *signal,
215 const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
216
217#ifdef Q_QDOC
218 template<typename PointerToMemberFunction>
219 static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection);
220 template<typename PointerToMemberFunction, typename Functor>
221 static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor);
222 template<typename PointerToMemberFunction, typename Functor>
223 static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type = Qt::AutoConnection);
224#else
225 //connect with context
226 template <typename Func1, typename Func2>
227 static inline QMetaObject::Connection
231 {
232 typedef QtPrivate::FunctionPointer<Func1> SignalType;
234
235 if constexpr (SlotType::ArgumentCount != -1) {
237 "Return type of the slot is not compatible with the return type of the signal.");
238 } else {
239 constexpr int FunctorArgumentCount = QtPrivate::ComputeFunctorArgumentCount<std::decay_t<Func2>, typename SignalType::Arguments>::Value;
240 [[maybe_unused]]
241 constexpr int SlotArgumentCount = (FunctorArgumentCount >= 0) ? FunctorArgumentCount : 0;
243
245 "Return type of the slot is not compatible with the return type of the signal.");
246 }
247
249 "No Q_OBJECT in the class with the signal");
250
251 //compilation error if the arguments does not match.
252 static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
253 "The slot requires more arguments than the signal provides.");
254
255 const int *types = nullptr;
258
259 void **pSlot = nullptr;
260 if constexpr (std::is_member_function_pointer_v<std::decay_t<Func2>>) {
261 pSlot = const_cast<void **>(reinterpret_cast<void *const *>(&slot));
262 } else {
264 "QObject::connect: Unique connection requires the slot to be a pointer to "
265 "a member function of a QObject subclass.");
266 }
267
268 return connectImpl(sender, reinterpret_cast<void **>(&signal), context, pSlot,
269 QtPrivate::makeCallableObject<Func1>(std::forward<Func2>(slot)),
270 type, types, &SignalType::Object::staticMetaObject);
271 }
272
273#ifndef QT_NO_CONTEXTLESS_CONNECT
274 //connect without context
275 template <typename Func1, typename Func2>
276 static inline QMetaObject::Connection
277 connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 &&slot)
278 {
279 return connect(sender, signal, sender, std::forward<Func2>(slot), Qt::DirectConnection);
280 }
281#endif // QT_NO_CONTEXTLESS_CONNECT
282#endif //Q_QDOC
283
284 static bool disconnect(const QObject *sender, const char *signal,
285 const QObject *receiver, const char *member);
286 static bool disconnect(const QObject *sender, const QMetaMethod &signal,
287 const QObject *receiver, const QMetaMethod &member);
288 inline bool disconnect(const char *signal = nullptr,
289 const QObject *receiver = nullptr, const char *member = nullptr) const
290 { return disconnect(this, signal, receiver, member); }
291 inline bool disconnect(const QObject *receiver, const char *member = nullptr) const
292 { return disconnect(this, nullptr, receiver, member); }
293 static bool disconnect(const QMetaObject::Connection &);
294
295#ifdef Q_QDOC
296 template<typename PointerToMemberFunction>
297 static bool disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method);
298#else
299 template <typename Func1, typename Func2>
300 static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
301 const typename QtPrivate::FunctionPointer<Func2>::Object *receiver, Func2 slot)
302 {
303 typedef QtPrivate::FunctionPointer<Func1> SignalType;
304 typedef QtPrivate::FunctionPointer<Func2> SlotType;
305
307 "No Q_OBJECT in the class with the signal");
308
309 //compilation error if the arguments does not match.
311 "Signal and slot arguments are not compatible.");
312
313 return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, reinterpret_cast<void **>(&slot),
314 &SignalType::Object::staticMetaObject);
315 }
316 template <typename Func1>
317 static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
318 const QObject *receiver, void **zero)
319 {
320 // This is the overload for when one wish to disconnect a signal from any slot. (slot=nullptr)
321 // Since the function template parameter cannot be deduced from '0', we use a
322 // dummy void ** parameter that must be equal to 0
323 Q_ASSERT(!zero);
324 typedef QtPrivate::FunctionPointer<Func1> SignalType;
325 return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, zero,
326 &SignalType::Object::staticMetaObject);
327 }
328#endif //Q_QDOC
329
330 void dumpObjectTree() const;
331 void dumpObjectInfo() const;
332
333 QT_CORE_INLINE_SINCE(6, 6)
334 bool setProperty(const char *name, const QVariant &value);
335 inline bool setProperty(const char *name, QVariant &&value);
336 QVariant property(const char *name) const;
337 QList<QByteArray> dynamicPropertyNames() const;
338 QBindingStorage *bindingStorage() { return &d_ptr->bindingStorage; }
339 const QBindingStorage *bindingStorage() const { return &d_ptr->bindingStorage; }
340
342 void destroyed(QObject * = nullptr);
343 void objectNameChanged(const QString &objectName, QPrivateSignal);
344
345public:
346 inline QObject *parent() const { return d_ptr->parent; }
347
348 inline bool inherits(const char *classname) const
349 {
350 return const_cast<QObject *>(this)->qt_metacast(classname) != nullptr;
351 }
352
353public Q_SLOTS:
354 void deleteLater();
355
356protected:
357 QObject *sender() const;
358 int senderSignalIndex() const;
359 int receivers(const char *signal) const;
360 bool isSignalConnected(const QMetaMethod &signal) const;
361
362 virtual void timerEvent(QTimerEvent *event);
363 virtual void childEvent(QChildEvent *event);
364 virtual void customEvent(QEvent *event);
365
366 virtual void connectNotify(const QMetaMethod &signal);
367 virtual void disconnectNotify(const QMetaMethod &signal);
368
369protected:
370 QObject(QObjectPrivate &dd, QObject *parent = nullptr);
371
372protected:
373 QScopedPointer<QObjectData> d_ptr;
374
375 friend struct QMetaObject;
376 friend struct QMetaObjectPrivate;
377 friend class QMetaCallEvent;
378 friend class QApplication;
380 friend class QCoreApplication;
382 friend class QWidget;
383 friend class QAccessibleWidget;
384 friend class QThreadData;
385
386private:
387 void doSetObjectName(const QString &name);
388 bool doSetProperty(const char *name, const QVariant *lvalue, QVariant *rvalue);
389
390 Q_DISABLE_COPY(QObject)
391
392private:
393 static QMetaObject::Connection connectImpl(const QObject *sender, void **signal,
394 const QObject *receiver, void **slotPtr,
396 const int *types, const QMetaObject *senderMetaObject);
397
398 static bool disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot,
399 const QMetaObject *senderMetaObject);
400
401};
402
403inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,
404 const char *amember, Qt::ConnectionType atype) const
405{ return connect(asender, asignal, this, amember, atype); }
406
407#if QT_CORE_INLINE_IMPL_SINCE(6, 6)
408bool QObject::setProperty(const char *name, const QVariant &value)
409{
410 return doSetProperty(name, &value, nullptr);
411}
412#endif // inline since 6.6
414{
415 return doSetProperty(name, &value, &value);
416}
417
418template <class T>
419inline T qobject_cast(QObject *object)
420{
421 static_assert(std::is_pointer_v<T>,
422 "qobject_cast requires to cast towards a pointer type");
423 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
425 "qobject_cast requires the type to have a Q_OBJECT macro");
426 return static_cast<T>(ObjType::staticMetaObject.cast(object));
427}
428
429template <class T>
430inline T qobject_cast(const QObject *object)
431{
432 static_assert(std::is_pointer_v<T>,
433 "qobject_cast requires to cast towards a pointer type");
434 static_assert(std::is_const_v<std::remove_pointer_t<T>>,
435 "qobject_cast cannot cast away constness (use const_cast)");
436 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
438 "qobject_cast requires the type to have a Q_OBJECT macro");
439 return static_cast<T>(ObjType::staticMetaObject.cast(object));
440}
441
442
443template <class T> constexpr const char * qobject_interface_iid() = delete;
444template <class T> inline T *
445qobject_iid_cast(QObject *object, const char *IId = qobject_interface_iid<T *>())
446{
447 return reinterpret_cast<T *>((object ? object->qt_metacast(IId) : nullptr));
448}
449template <class T> inline std::enable_if_t<std::is_const<T>::value, T *>
451{
452 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
453 QObject *o = const_cast<QObject *>(object);
454 return qobject_iid_cast<std::remove_cv_t<T>>(o);
455}
456
457#if defined(Q_QDOC)
458# define Q_DECLARE_INTERFACE(IFace, IId)
459#elif !defined(Q_MOC_RUN)
460# define Q_DECLARE_INTERFACE(IFace, IId) \
461 template <> constexpr const char *qobject_interface_iid<IFace *>() \
462 { return IId; } \
463 template <> inline IFace *qobject_cast<IFace *>(QObject *object) \
464 { return qobject_iid_cast<IFace>(object); } \
465 template <> inline const IFace *qobject_cast<const IFace *>(const QObject *object) \
466 { return qobject_iid_cast<const IFace>(object); }
467#endif // Q_MOC_RUN
468
470{
471 return o->bindingStorage();
472}
474{
475 return o->bindingStorage();
476}
477
478#ifndef QT_NO_DEBUG_STREAM
479Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *);
480#endif
481
483{
484public:
486 inline explicit QSignalBlocker(QObject *o) noexcept;
488 inline explicit QSignalBlocker(QObject &o) noexcept;
489 inline ~QSignalBlocker();
490
492 inline QSignalBlocker(QSignalBlocker &&other) noexcept;
493 inline QSignalBlocker &operator=(QSignalBlocker &&other) noexcept;
494
495 inline void reblock() noexcept;
496 inline void unblock() noexcept;
497 inline void dismiss() noexcept;
498
499private:
500 Q_DISABLE_COPY(QSignalBlocker)
501 QObject *m_o;
502 bool m_blocked;
503 bool m_inhibited;
504};
505
507 : m_o(o),
508 m_blocked(o && o->blockSignals(true)),
509 m_inhibited(false)
510{}
511
513 : m_o(&o),
514 m_blocked(o.blockSignals(true)),
515 m_inhibited(false)
516{}
517
519 : m_o(other.m_o),
520 m_blocked(other.m_blocked),
521 m_inhibited(other.m_inhibited)
522{
523 other.m_o = nullptr;
524}
525
527{
528 if (this != &other) {
529 // if both *this and other block the same object's signals:
530 // unblock *this iff our dtor would unblock, but other's wouldn't
531 if (m_o != other.m_o || (!m_inhibited && other.m_inhibited))
532 unblock();
533 m_o = other.m_o;
534 m_blocked = other.m_blocked;
535 m_inhibited = other.m_inhibited;
536 // disable other:
537 other.m_o = nullptr;
538 }
539 return *this;
540}
541
543{
544 if (m_o && !m_inhibited)
545 m_o->blockSignals(m_blocked);
546}
547
549{
550 if (m_o)
551 m_o->blockSignals(true);
552 m_inhibited = false;
553}
554
556{
557 if (m_o)
558 m_o->blockSignals(m_blocked);
559 m_inhibited = true;
560}
561
563{
564 m_o = nullptr;
565}
566
567namespace QtPrivate {
568 inline QObject & deref_for_methodcall(QObject &o) { return o; }
569 inline QObject & deref_for_methodcall(QObject *o) { return *o; }
570}
571#define Q_SET_OBJECT_NAME(obj) QT_PREPEND_NAMESPACE(QtPrivate)::deref_for_methodcall(obj).setObjectName(QLatin1StringView(#obj))
572
574
575#endif
576
577#endif // QOBJECT_H
\inmodule QtCore
The QApplication class manages the GUI application's control flow and main settings.
\inmodule QtCore
Definition qatomic.h:112
\inmodule QtCore
Definition qproperty.h:811
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qcoreevent.h:379
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtCore
Definition qmetaobject.h:19
\inmodule QtCore Represents a handle to a signal-slot (or signal-functor) connection.
QDynamicMetaObjectData * metaObject
Definition qobject.h:90
uint isDeletingChildren
Definition qobject.h:79
uint isWindow
Definition qobject.h:82
uint receiveChildEvents
Definition qobject.h:81
uint wasDeleted
Definition qobject.h:78
QObject * q_ptr
Definition qobject.h:72
uint deleteLaterCalled
Definition qobject.h:83
uint receiveParentEvents
Definition qobject.h:87
uint unused
Definition qobject.h:88
uint isQuickItem
Definition qobject.h:84
uint isWidget
Definition qobject.h:76
uint sendChildEvents
Definition qobject.h:80
QAtomicInt postedEvents
Definition qobject.h:89
QObjectList children
Definition qobject.h:74
uint blockSig
Definition qobject.h:77
uint wasWidget
Definition qobject.h:86
uint willBeWidget
Definition qobject.h:85
QObject * parent
Definition qobject.h:73
QBindingStorage bindingStorage
Definition qobject.h:91
QObjectData()=default
\inmodule QtCore
Definition qobject.h:103
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
Definition qobject.h:317
bool disconnect(const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
Definition qobject.h:288
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
Definition qobject.h:228
T findChild(QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns the child of this object that can be cast into type T and that is called name,...
Definition qobject.h:155
const QObjectList & children() const
Returns a list of child objects.
Definition qobject.h:201
bool isWindowType() const
Returns true if the object is a window; otherwise returns false.
Definition qobject.h:132
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
QList< T > findChildren(Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qobject.h:182
const QBindingStorage * bindingStorage() const
Definition qobject.h:339
bool signalsBlocked() const noexcept
Returns true if signals are blocked; otherwise returns false.
Definition qobject.h:135
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
Definition qobject.h:277
QList< T > findChildren(QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns all children of this object with the given name that can be cast to type T,...
Definition qobject.h:164
bool isQuickItemType() const
Returns true if the object is a QQuickItem; otherwise returns false.
Definition qobject.h:133
QScopedPointer< QObjectData > d_ptr
Definition qobject.h:373
bool blockSignals(bool b) noexcept
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
Definition qobject.cpp:1585
T findChild(Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qobject.h:176
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
Definition qobject.h:127
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
Definition qobject.h:300
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
bool disconnect(const QObject *receiver, const char *member=nullptr) const
Definition qobject.h:291
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition qobject.h:348
void objectNameChanged(const QString &objectName, QPrivateSignal)
This signal is emitted after the object's name has been changed.
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition qobject.h:131
\inmodule QtCore \reentrant
Exception-safe wrapper around QObject::blockSignals().
Definition qobject.h:483
void dismiss() noexcept
Definition qobject.h:562
void unblock() noexcept
Temporarily restores the QObject::signalsBlocked() state to what it was before this QSignalBlocker's ...
Definition qobject.h:555
void reblock() noexcept
Re-blocks signals after a previous unblock().
Definition qobject.h:548
QSignalBlocker & operator=(QSignalBlocker &&other) noexcept
Move-assigns this signal blocker from other.
Definition qobject.h:526
Q_NODISCARD_CTOR QSignalBlocker(QObject *o) noexcept
Constructor.
Definition qobject.h:506
~QSignalBlocker()
Destructor.
Definition qobject.h:542
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6018
\inmodule QtCore
Definition qcoreevent.h:366
\inmodule QtCore
Definition qvariant.h:65
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
auto signal
object setObjectName("A new object name")
auto mo
[7]
Combined button and popup list for selecting options.
\macro QT_NO_KEYWORDS >
QObject & deref_for_methodcall(QObject &o)
Definition qobject.h:568
TimerType
@ CoarseTimer
@ FindChildrenRecursively
ConnectionType
@ AutoConnection
@ BlockingQueuedConnection
@ QueuedConnection
@ UniqueConnection
@ DirectConnection
static void * context
#define Q_NODISCARD_CTOR
#define Q_WEAK_OVERLOAD
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
void qt_qFindChildren_helper(const QObject *parent, QAnyStringView name, const QMetaObject &mo, QList< void * > *list, Qt::FindChildOptions options)
Definition qobject.cpp:2137
QObject * qt_qFindChild_helper(const QObject *parent, QAnyStringView name, const QMetaObject &mo, Qt::FindChildOptions options)
Definition qobject.cpp:2174
const QBindingStorage * qGetBindingStorage(const QObject *o)
Definition qobject.h:469
constexpr const char * qobject_interface_iid()=delete
Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, QAnyStringView name, const QMetaObject &mo, QList< void * > *list, Qt::FindChildOptions options)
Definition qobject.cpp:2137
T * qobject_iid_cast(QObject *object, const char *IId=qobject_interface_iid< T * >())
Definition qobject.h:445
QList< QObject * > QObjectList
Definition qobject.h:45
T qobject_cast(QObject *object)
\variable QObject::staticMetaObject
Definition qobject.h:419
Q_CORE_EXPORT QObject * qt_qFindChild_helper(const QObject *parent, QAnyStringView name, const QMetaObject &mo, Qt::FindChildOptions options)
Definition qobject.cpp:2174
Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *)
Definition qobject.cpp:4481
GLboolean GLboolean GLboolean b
GLsizei GLenum GLenum * types
GLuint object
[3]
GLenum type
GLuint name
struct _cl_event * event
GLhandleARB obj
[2]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_ASSERT_X(cond, x, msg)
Definition qrandom.cpp:48
#define zero
#define tr(X)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_SLOTS
#define Q_SIGNALS
#define QT6_DECL_NEW_OVERLOAD_TAIL
unsigned int uint
Definition qtypes.h:34
const char property[13]
Definition qwizard.cpp:101
QList< int > list
[14]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
monitoredObj installEventFilter(filterObj)
[13]
myObject disconnect()
[26]
myObject moveToThread(QApplication::instance() ->thread())
[6]
someQObject blockSignals(wasBlocked)
QSharedPointer< T > other(t)
[5]
file setParent(multiPart)
args<< 1<< 2;QJSValue threeAgain=fun.call(args);QString fileName="helloworld.qs";QFile scriptFile(fileName);if(!scriptFile.open(QIODevice::ReadOnly)) QTextStream stream(&scriptFile);QString contents=stream.readAll();scriptFile.close();myEngine.evaluate(contents, fileName);myEngine.globalObject().setProperty("myNumber", 123);...QJSValue myNumberPlusOne=myEngine.evaluate("myNumber + 1");QJSValue result=myEngine.evaluate(...);if(result.isError()) qDebug()<< "Uncaught exception at line"<< result.property("lineNumber").toInt()<< ":"<< result.toString();QPushButton *button=new QPushButton;QJSValue scriptButton=myEngine.newQObject(button);myEngine.globalObject().setProperty("button", scriptButton);myEngine.evaluate("button.checkable = true");qDebug()<< scriptButton.property("checkable").toBool();scriptButton.property("show").call();QJSEngine engine;QObject *myQObject=new QObject();myQObject- setProperty)("dynamicProperty", 3)
\inmodule QtCore
static const int * types()
List_Append< List< typenameL::Car >, typenameList_Left< typenameL::Cdr, N-1 >::Value >::Value Value