48 Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName
49 NOTIFY applicationNameChanged)
50 Q_PROPERTY(QString applicationVersion READ applicationVersion WRITE setApplicationVersion
51 NOTIFY applicationVersionChanged)
52 Q_PROPERTY(QString organizationName READ organizationName WRITE setOrganizationName
53 NOTIFY organizationNameChanged)
54 Q_PROPERTY(QString organizationDomain READ organizationDomain WRITE setOrganizationDomain
55 NOTIFY organizationDomainChanged)
56 Q_PROPERTY(
bool quitLockEnabled READ isQuitLockEnabled WRITE setQuitLockEnabled)
59 Q_DECLARE_PRIVATE(QCoreApplication)
60 friend class QEventLoopLocker;
61#if QT_CONFIG(permissions)
62 using RequestPermissionPrototype =
void(*)(QPermission);
66 enum { ApplicationFlags = QT_VERSION
69 QCoreApplication(
int &argc,
char **argv
71 ,
int = ApplicationFlags
77 static QStringList arguments();
79 static void setAttribute(Qt::ApplicationAttribute attribute,
bool on =
true);
80 static bool testAttribute(Qt::ApplicationAttribute attribute);
82 static void setOrganizationDomain(
const QString &orgDomain);
83 static QString organizationDomain();
84 static void setOrganizationName(
const QString &orgName);
85 static QString organizationName();
86 static void setApplicationName(
const QString &application);
87 static QString applicationName();
88 static void setApplicationVersion(
const QString &version);
89 static QString applicationVersion();
91 static void setSetuidAllowed(
bool allow);
92 static bool isSetuidAllowed();
94#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
95 static QCoreApplication *instance()
noexcept {
return self.loadRelaxed(); }
96 static bool instanceExists()
noexcept {
return instance() !=
nullptr; }
98# ifdef __cpp_lib_atomic_ref
99 static QCoreApplication *instance()
noexcept
100 {
return std::atomic_ref(self).load(std::memory_order_relaxed); }
102 static QCoreApplication *instance()
noexcept {
return self; }
104 static bool instanceExists()
noexcept;
109 static void processEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
110 static void processEvents(QEventLoop::ProcessEventsFlags flags,
int maxtime);
111 static void processEvents(QEventLoop::ProcessEventsFlags flags, QDeadlineTimer deadline);
113 static bool sendEvent(QObject *receiver, QEvent *event);
114 static void postEvent(QObject *receiver, QEvent *event,
int priority = Qt::NormalEventPriority);
115 static void sendPostedEvents(QObject *receiver =
nullptr,
int event_type = 0);
116 static void removePostedEvents(QObject *receiver,
int eventType = 0);
117 static QAbstractEventDispatcher *eventDispatcher();
118 static void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
120 virtual bool notify(QObject *, QEvent *);
122 static bool startingUp();
123 static bool closingDown();
126 static QString applicationDirPath();
127 static QString applicationFilePath();
128 Q_DECL_CONST_FUNCTION
static qint64 applicationPid()
noexcept;
130#if QT_CONFIG(permissions) || defined(Q_QDOC)
131 Qt::PermissionStatus checkPermission(
const QPermission &permission);
134 template <
typename Functor>
135 void requestPermission(
const QPermission &permission,
const QObject *context, Functor functor);
139 template <
typename Functor,
141 QtPrivate::AreFunctionsCompatible<RequestPermissionPrototype, Functor>::value,
143 void requestPermission(
const QPermission &permission,
144 const typename QtPrivate::ContextTypeForFunctor<Functor>::ContextType *receiver,
147 requestPermissionImpl(permission,
148 QtPrivate::makeCallableObject<RequestPermissionPrototype>(std::forward<Functor>(func)),
153#ifndef QT_NO_CONTEXTLESS_CONNECT
155 template <
typename Functor>
158 template <
typename Functor,
160 QtPrivate::AreFunctionsCompatible<RequestPermissionPrototype, Functor>::value,
163 void requestPermission(
const QPermission &permission, Functor &&func)
165 requestPermission(permission,
nullptr, std::forward<Functor>(func));
169#if QT_CORE_REMOVED_SINCE(6
, 10
)
171 void requestPermission(
const QPermission &permission,
172 QtPrivate::QSlotObjectBase *slotObj,
const QObject *context);
178#if QT_CONFIG(library)
179 static void setLibraryPaths(
const QStringList &);
180 static QStringList libraryPaths();
181 static void addLibraryPath(
const QString &);
182 static void removeLibraryPath(
const QString &);
185#ifndef QT_NO_TRANSLATION
186 static bool installTranslator(QTranslator * messageFile);
187 static bool removeTranslator(QTranslator * messageFile);
190 static QString translate(
const char * context,
192 const char * disambiguation =
nullptr,
195 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QCoreApplication)
198 void installNativeEventFilter(QAbstractNativeEventFilter *filterObj);
199 void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj);
201 static bool isQuitLockEnabled();
202 static void setQuitLockEnabled(
bool enabled);
206 static void exit(
int retcode = 0);
209 void aboutToQuit(QPrivateSignal);
211 void organizationNameChanged();
212 void organizationDomainChanged();
213 void applicationNameChanged();
214 void applicationVersionChanged();
217 bool event(QEvent *) override;
219# if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
220 QT_DEPRECATED_VERSION_X_6_10(
"This feature will be removed in Qt 7")
221 virtual bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
226 QCoreApplication(QCoreApplicationPrivate &p);
229 std::unique_ptr<QCoreApplicationPrivate> d_ptr;
234 static bool sendSpontaneousEvent(QObject *receiver, QEvent *event);
235 static bool notifyInternal2(QObject *receiver, QEvent *);
236 static bool forwardEvent(QObject *receiver, QEvent *event, QEvent *originatingEvent =
nullptr);
238 void requestPermissionImpl(
const QPermission &permission, QtPrivate::QSlotObjectBase *slotObj,
239 const QObject *context);
242#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
243 static QBasicAtomicPointer<QCoreApplication> self;
245 static QCoreApplication *self;
248 Q_DISABLE_COPY(QCoreApplication)
250 friend class QApplication;
251 friend class QApplicationPrivate;
252 friend class QGuiApplication;
253 friend class QGuiApplicationPrivate;
254 friend class QWidget;
255 friend class QWidgetWindow;
256 friend class QWidgetPrivate;
257 friend class QWindowPrivate;
259 friend class QEventDispatcherUNIXPrivate;
260 friend class QCocoaEventDispatcherPrivate;
261 friend bool qt_sendSpontaneousEvent(QObject *, QEvent *);
263 friend Q_CORE_EXPORT QString qAppName();
264 friend class QCommandLineParserPrivate;