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>
17#include <QtCore/qscopedpointer.h>
18#include <QtCore/qmetatype.h>
20#include <QtCore/qobject_impl.h>
21#include <QtCore/qbindingstorage.h>
22#include <QtCore/qtcoreexports.h>
39class QAccessibleWidget;
40#if QT_CONFIG(regularexpression)
47#if QT_CORE_REMOVED_SINCE(6, 7)
53 Qt::FindChildOptions options);
54#if QT_CORE_REMOVED_SINCE(6, 7)
56 QList<void *> *
list, Qt::FindChildOptions options);
60#if QT_CORE_REMOVED_SINCE(6, 7)
98 enum { CheckForParentChildLoopsWarnDepth = 4096 };
107 BINDABLE bindableObjectName)
117#if defined(QT_NO_TRANSLATION) || defined(Q_QDOC)
118 static QString tr(
const char *sourceText,
const char * =
nullptr,
int = -1)
123#if QT_CORE_REMOVED_SINCE(6, 4)
129 QBindable<QString> bindableObjectName();
139#if QT_CORE_REMOVED_SINCE(6, 7)
146#if QT_CORE_REMOVED_SINCE(6, 8)
151 void killTimer(
int id);
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");
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");
171 reinterpret_cast<QList<void *> *
>(&
list), options);
178 return findChild<T>({}, options);
187#if QT_CONFIG(regularexpression)
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");
196 reinterpret_cast<QList<void *> *
>(&
list), options);
218 template<
typename Po
interToMemberFunction>
220 template<
typename Po
interToMemberFunction,
typename Functor>
222 template<
typename Po
interToMemberFunction,
typename Functor>
226 template <
typename Func1,
typename Func2>
235 if constexpr (SlotType::ArgumentCount != -1) {
237 "Return type of the slot is not compatible with the return type of the signal.");
241 constexpr int SlotArgumentCount = (FunctorArgumentCount >= 0) ? FunctorArgumentCount : 0;
245 "Return type of the slot is not compatible with the return type of the signal.");
249 "No Q_OBJECT in the class with the signal");
252 static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
253 "The slot requires more arguments than the signal provides.");
255 const int *
types =
nullptr;
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));
264 "QObject::connect: Unique connection requires the slot to be a pointer to "
265 "a member function of a QObject subclass.");
268 return connectImpl(sender,
reinterpret_cast<void **
>(&
signal),
context, pSlot,
269 QtPrivate::makeCallableObject<Func1>(std::forward<Func2>(slot)),
270 type,
types, &SignalType::Object::staticMetaObject);
273#ifndef QT_NO_CONTEXTLESS_CONNECT
275 template <
typename Func1,
typename Func2>
285 const QObject *receiver,
const char *member);
289 const QObject *receiver =
nullptr,
const char *member =
nullptr)
const
292 {
return disconnect(
this,
nullptr, receiver, member); }
296 template<
typename Po
interToMemberFunction>
299 template <
typename Func1,
typename Func2>
307 "No Q_OBJECT in the class with the signal");
311 "Signal and slot arguments are not compatible.");
313 return disconnectImpl(sender,
reinterpret_cast<void **
>(&
signal), receiver,
reinterpret_cast<void **
>(&slot),
314 &SignalType::Object::staticMetaObject);
316 template <
typename Func1>
325 return disconnectImpl(sender,
reinterpret_cast<void **
>(&
signal), receiver,
zero,
326 &SignalType::Object::staticMetaObject);
330 void dumpObjectTree()
const;
331 void dumpObjectInfo()
const;
333 QT_CORE_INLINE_SINCE(6, 6)
350 return const_cast<QObject *
>(
this)->qt_metacast(classname) !=
nullptr;
358 int senderSignalIndex()
const;
359 int receivers(
const char *
signal)
const;
383 friend class QAccessibleWidget;
394 const QObject *receiver,
void **slotPtr,
398 static bool disconnectImpl(
const QObject *sender,
void **
signal,
const QObject *receiver,
void **slot,
405{
return connect(asender, asignal,
this, amember, atype); }
407#if QT_CORE_INLINE_IMPL_SINCE(6, 6)
410 return doSetProperty(
name, &
value,
nullptr);
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));
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));
444template <
class T>
inline T *
447 return reinterpret_cast<T *
>((
object ?
object->qt_metacast(IId) :
nullptr));
449template <
class T>
inline std::enable_if_t<std::is_const<T>::value, T *>
454 return qobject_iid_cast<std::remove_cv_t<T>>(
o);
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 *>() \
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); }
471 return o->bindingStorage();
475 return o->bindingStorage();
478#ifndef QT_NO_DEBUG_STREAM
495 inline void reblock()
noexcept;
496 inline void unblock()
noexcept;
497 inline void dismiss()
noexcept;
508 m_blocked(
o &&
o->blockSignals(
true)),
514 m_blocked(
o.blockSignals(
true)),
520 m_blocked(
other.m_blocked),
521 m_inhibited(
other.m_inhibited)
528 if (
this != &
other) {
531 if (m_o !=
other.m_o || (!m_inhibited &&
other.m_inhibited))
534 m_blocked =
other.m_blocked;
535 m_inhibited =
other.m_inhibited;
544 if (m_o && !m_inhibited)
571#define Q_SET_OBJECT_NAME(obj) QT_PREPEND_NAMESPACE(QtPrivate)::deref_for_methodcall(obj).setObjectName(QLatin1StringView(#obj))
The QApplication class manages the GUI application's control flow and main settings.
QDynamicMetaObjectData * metaObject
QBindingStorage bindingStorage
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
bool disconnect(const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
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)
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,...
const QObjectList & children() const
Returns a list of child objects.
bool isWindowType() const
Returns true if the object is a window; otherwise returns false.
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
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...
const QBindingStorage * bindingStorage() const
bool signalsBlocked() const noexcept
Returns true if signals are blocked; otherwise returns false.
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
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,...
bool isQuickItemType() const
Returns true if the object is a QQuickItem; otherwise returns false.
QScopedPointer< QObjectData > d_ptr
bool blockSignals(bool b) noexcept
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
T findChild(Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
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
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...
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.
\inmodule QtCore \reentrant
Exception-safe wrapper around QObject::blockSignals().
void unblock() noexcept
Temporarily restores the QObject::signalsBlocked() state to what it was before this QSignalBlocker's ...
void reblock() noexcept
Re-blocks signals after a previous unblock().
QSignalBlocker & operator=(QSignalBlocker &&other) noexcept
Move-assigns this signal blocker from other.
Q_NODISCARD_CTOR QSignalBlocker(QObject *o) noexcept
Constructor.
~QSignalBlocker()
Destructor.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
object setObjectName("A new object name")
Combined button and popup list for selecting options.
QObject & deref_for_methodcall(QObject &o)
@ FindChildrenRecursively
@ BlockingQueuedConnection
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)
QObject * qt_qFindChild_helper(const QObject *parent, QAnyStringView name, const QMetaObject &mo, Qt::FindChildOptions options)
const QBindingStorage * qGetBindingStorage(const QObject *o)
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)
T * qobject_iid_cast(QObject *object, const char *IId=qobject_interface_iid< T * >())
QList< QObject * > QObjectList
T qobject_cast(QObject *object)
\variable QObject::staticMetaObject
Q_CORE_EXPORT QObject * qt_qFindChild_helper(const QObject *parent, QAnyStringView name, const QMetaObject &mo, Qt::FindChildOptions options)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *)
GLboolean GLboolean GLboolean b
GLsizei GLenum GLenum * types
#define Q_ASSERT_X(cond, x, msg)
#define QT6_DECL_NEW_OVERLOAD_TAIL
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)
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)
static const int * types()
List_Append< List< typenameL::Car >, typenameList_Left< typenameL::Cdr, N-1 >::Value >::Value Value