CopperSpice API  1.9.1
QCoreApplication Class Reference

Implements an event loop for console applications. More...

Inheritance diagram for QCoreApplication:
QObject QApplication

Public Signals

void aboutToQuit ()
 
void unixSignal (int signalId)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

static void quit ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QCoreApplication (int &argc, char **argv)
 
 ~QCoreApplication ()
 
void installNativeEventFilter (QAbstractNativeEventFilter *filterObj)
 
virtual bool notify (QObject *receiver, QEvent *event)
 
void removeNativeEventFilter (QAbstractNativeEventFilter *filterObj)
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Static Public Methods

static void addLibraryPath (const QString &path)
 
static QString applicationDirPath ()
 
static QString applicationFilePath ()
 
static QString applicationName ()
 
static qint64 applicationPid ()
 
static QString applicationVersion ()
 
static QStringList arguments ()
 
static bool closingDown ()
 
static int exec ()
 
static void exit (int returnCode=0)
 
static void flush ()
 
static void installTranslator (QTranslator *translationFile)
 
static QCoreApplication * instance ()
 
static bool isQuitLockEnabled ()
 
static bool isSetuidAllowed ()
 
static QStringList libraryPaths ()
 
static QString organizationDomain ()
 
static QString organizationName ()
 
static void postEvent (QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
 
static void processEvents (QEventLoop::ProcessEventsFlags flags, int maxtime)
 
static void processEvents (QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
 
static void removeLibraryPath (const QString &path)
 
static void removePostedEvents (QObject *receiver, int eventType=0)
 
static void removeTranslator (QTranslator *translationFile)
 
static bool sendEvent (QObject *receiver, QEvent *event)
 
static void sendPostedEvents (QObject *receiver=nullptr, int event_type=0)
 
static void setApplicationName (const QString &application)
 
static void setApplicationVersion (const QString &version)
 
static void setAttribute (Qt::ApplicationAttribute attribute, bool on=true)
 
static void setLibraryPaths (const QStringList &paths)
 
static void setOrganizationDomain (const QString &orgDomain)
 
static void setOrganizationName (const QString &orgName)
 
static void setQuitLockEnabled (bool enabled)
 
static void setSetuidAllowed (bool allow)
 
static bool startingUp ()
 
static bool testAttribute (Qt::ApplicationAttribute attribute)
 
static QString translate (const char *context, const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
static QString translate (const QString &context, const QString &text, const QString &comment=QString (), std::optional< int > numArg=std::optional< int >())
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 

Protected Methods

bool event (QEvent *) override
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Properties

 applicationName
 
 applicationVersion
 
 organizationDomain
 
 organizationName
 
 quitLockEnabled
 
- Properties inherited from QObject
 objectName
 

Friends

class QApplication
 
class QWidget
 

Related Functions

These are not member functions

void qAddPostRoutine (QtCleanUpFunction ptr)
 
void qRemovePostRoutine (QtCleanUpFunction ptr)
 

Detailed Description

The QCoreApplication class provides an event loop for console applications. This class is used by non-GUI applications to provide their event loop. There should be exactly one QCoreApplication object for a given program. For GUI applications refer to QApplication.

QCoreApplication contains the main event loop, where all events from the operating system and other sources are processed and dispatched. For example, timer and network events are handled by this class. It also handles the application's initialization and finalization, as well as system wide and application wide settings.

Event Loop and Event Handling

The event loop is started with a call to exec(). Long running operations can call processEvents() to keep the application responsive.

In general it is recommended to create a QCoreApplication or a QApplication object in your main() function as early as possible. Calling exec() will not return until the event loop exits, when quit() is called.

Several static methods are also provided. The QCoreApplication object is available by calling QCoreApplication::instance(). Events can be sent or posted using sendEvent(), postEvent(), and sendPostedEvents(). Pending events can be removed with removePostedEvents() or flushed with flush(). This class provides an aboutToQuit() signal and a quit() slot.

Application and Library Paths

An application has an applicationDirPath() and an applicationFilePath(). Library paths (see QLibrary) can be retrieved with libraryPaths() and manipulated by setLibraryPaths(), addLibraryPath(), and removeLibraryPath().

Internationalization and Translations

Translation files can be added or removed using installTranslator() and removeTranslator(). Application strings can be translated using translate() or QObject::tr().

Accessing Command Line Arguments

The command line arguments which are passed to the QCoreApplication constructor should be accessed using the arguments() method. Some of the arguments which were supplied by the user may be processed and removed by QCoreApplication.

The argv argument are processed by QCoreApplication and can be retrieved using the arguments() method.

Locale Settings

On Unix systems CopperSpice is configured to use the system locale settings by default. This can cause a conflict when using POSIX functions. For example, when converting between data types such as floats and strings, the format may differ between locales.

To solve this, call the POSIX function setlocale(LC_NUMERIC, "C") directly after initializing QApplication or QCoreApplication to set the locale for number formatting.

See also
QApplication, QAbstractEventDispatcher, QEventLoop

Constructor & Destructor Documentation

QCoreApplication::QCoreApplication ( int &  argc,
char **  argv 
)

Constructs a CopperSpice application without a graphical user interface. This type of application is typically used for terminal or server process. The argc and argv arguments are processed by QCoreApplication and can be retrieved using the arguments() method.

Note
The data referred to by argc and argv must remain valid for the entire lifetime of the QCoreApplication object. In addition argc must be greater than zero and argv must contain at least one valid character string.
QCoreApplication::~QCoreApplication ( )

Destroys the QCoreApplication object.

Method Documentation

void QCoreApplication::aboutToQuit ( )
signal

This signal is emitted when the application is about to quit the main event loop, e.g. when the event loop level drops to zero. This may happen either after a call to quit() from inside the application or when the users shuts down the entire desktop session.

The signal is particularly useful if your application has to do some last-second cleanup. No user interaction is possible in this state.

See also
quit()
void QCoreApplication::addLibraryPath ( const QString path)
static

Prepends path to the beginning of the library path list, ensuring that it is searched for libraries first. If path is empty or already in the path list, the path list is not changed.

The default path list consists of a single entry, the installation directory for plugins. The default installation directory for plugins is INSTALL/plugins, where INSTALL is the directory where CopperSpice was installed.

See also
removeLibraryPath(), libraryPaths(), setLibraryPaths()
QString QCoreApplication::applicationDirPath ( )
static

Returns the directory which contains the application executable. The return value will be absolute or relative to the working directory. If present, any path separators will be a forward slash.

On Linux the path can be obtained from the /proc file system. If that fails argv[0] contains the absolute file name of the executable.

On Mac OS X the path will point to the directory actually containing the executable which may be inside of an application bundle.

See also
applicationFilePath()
QString QCoreApplication::applicationFilePath ( )
static

Returns the file path of the application executable.

On Linux this method will try to get the path from the /proc file system. If that fails, it assumes that argv[0] contains the absolute file name of the executable. The method assumes the current directory has not been changed by the application.

See also
applicationDirPath()
QString QCoreApplication::applicationName ( )
static

Returns the value of the property applicationName.

qint64 QCoreApplication::applicationPid ( )
static

Returns the current process ID for the application.

QString QCoreApplication::applicationVersion ( )
static

Returns the value of the property applicationVersion.

QStringList QCoreApplication::arguments ( )
static

Returns the list of command line arguments.

Usually arguments().at(0) is the program name and arguments().at(1) is the first argument and so on. Calling this method can be slow so you may want to store the result in a variable.

On Unix the return value is created from the argc and argv parameters passed to the QCoreApplication constructor. This method calls QString8::fromUtf8() to convert the argv data before saving it to the QStringList.

On Windows the return value is not built from the contents of argv and argc. Instead, the values are based on the return values of the GetCommandLine() function. As a result arguments().at(0) might not be the program name on Windows, depending on how the application was started.

See also
applicationFilePath()
bool QCoreApplication::closingDown ( )
static

Returns true if the application objects are being destroyed, otherwise returns false.

See also
startingUp()
bool QCoreApplication::event ( QEvent event)
overrideprotectedvirtual

Receives events to an object and should return true if the given event was recognized and processed. This method can be overridden to customize the event handling for an object.

See also
installEventFilter(), timerEvent(), QApplication::sendEvent(), QApplication::postEvent(), QWidget::event()

Reimplemented from QObject::event()

Reimplemented in QApplication::event()

int QCoreApplication::exec ( )
static

Enters the main event loop and waits until exit() is called. Returns the value that was set to exit() (which is 0 if exit() is called via quit()).

It is necessary to call this function to start event handling. The main event loop receives events from the window system and dispatches these to the application widgets.

To make your application perform idle processing (i.e. executing a special function whenever there are no pending events), use a QTimer with 0 timeout. More advanced idle processing schemes can be achieved using processEvents().

We recommend that you connect clean-up code to the aboutToQuit() signal, instead of putting it in your application's main() function because on some platforms the QCoreApplication::exec() call may not return. For example, on Windows when the user logs off, the system terminates the process after CopperSpice closes all top-level windows. Hence, there is no guarantee that the application will have time to exit its event loop and execute code at the end of the main() function after the QCoreApplication::exec() call.

See also
quit(), exit(), processEvents(), QApplication::exec()
void QCoreApplication::exit ( int  returnCode = 0)
static

Forces the application to exit with a return code. After calling this method the application leaves the main event loop and returns from the call to exec(). If the event loop is not running this method does nothing.

The exec() method will return the value returnCode. A returnCode of 0 means success and any non-zero value indicates an error.

Unlike the C library function of the same name this method does return to the caller and as a side effect stops the event loop.

See also
quit(), exec()
void QCoreApplication::flush ( )
static

Flushes the platform specific event queues.

If you are doing graphical changes inside a loop that does not return to the event loop on asynchronous window systems like X11 or double buffered window systems like Mac OS X, and you want to visualize these changes immediately (e.g. Splash Screens), call this method.

See also
sendPostedEvents()
void QCoreApplication::installNativeEventFilter ( QAbstractNativeEventFilter filterObj)

Installs an event filter filterObj for all native events received by the application in the main thread. Each time a native event occurs a call is made to the nativeEventFilter() method located in the filterObj. This call only occurs in the main thread.

Returning false allows normal processing to continue. The native event is then converted into a QEvent and passed to the standard event system. If multiple event filters are installed the filter which was installed last is activated first. The nativeEventFilter() method receives native messages like "X11 MSG" or "XCB" event structs.

Native event filters will be disabled in the application when the Qt::AA_MacPluginApplication attribute is set.

When implementing nativeEventFilter(), returning true causes the event to be filtered and ignored. For portability use QEvent and QObject::installEventFilter() instead of the nativeEventFilter() method.

See also
QObject::installEventFilter()
void QCoreApplication::installTranslator ( QTranslator translationFile)
static

Adds the translationFile to the list of existing files which will be used to translate a given piece of text. Multiple translation files can be installed and they are accessed in the reverse order in which they were installed. The search for a given piece of text stops when a translation containing a match is found.

Installing, removing, or changing an installed QTranslator generates a LanguageChange event in QCoreApplication. This event is propagated to all toplevel windows. If an override for the changeEvent() method exists, the window will be notified to update any text which is affected.

See also
removeTranslator(), translate(), QTranslator::load(), Dynamic Translation
QCoreApplication * QCoreApplication::instance ( )
inlinestatic

Returns a pointer to the application's QCoreApplication (or QApplication) instance. If no instance has been allocated a nullptr is returned.

bool QCoreApplication::isQuitLockEnabled ( )
static

Returns the value of the property quitLockEnabled.

bool QCoreApplication::isSetuidAllowed ( )
static

Returns true if the application is allowed to run setuid on UNIX platforms.

See also
setSetuidAllowed()
QStringList QCoreApplication::libraryPaths ( )
static

Returns a list of paths the application will search when dynamically loading libraries. It is not recommended to call this method before creating a QCoreApplication. The directory of the application executable (not the working directory) is part of the list if it is known.

CopperSpice provides default library paths, however they can also be set using a cs.conf file. Paths specified in this file will override default values. Refer to Plugin Path Configuration for more information.

This list will include the installation directory for plugins if it exists (the default installation directory for plugins is INSTALL/plugins, where INSTALL is the directory where CopperSpice was installed). The directory of the application executable (NOT the working directory) is always added, as well as the colon separated entries of the CS_PLUGIN_PATH environment variable.

The following example shows how to iterate over the list of library paths.

for (const QString &path : app.libraryPaths()) {
do_something(path);
}
See also
setLibraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary, Creating Plugins
bool QCoreApplication::notify ( QObject receiver,
QEvent event 
)
virtual

Sends event to receiver as if you had called "receiver->event(event)". Returns the value that is returned from the receiver's event handler. This method is called for all events sent to any object in any thread.

For certain types of events (e.g. mouse and key events), the event will be propagated to the receiver's parent and so on up to the top-level object if the receiver is not interested in the event (i.e., it returns false).

There are five different ways that events can be processed. Reimplementing this virtual function is just one of them. All five approaches are listed below:

  1. Reimplementing paintEvent(), mousePressEvent() and so on. This is the commonest, easiest and least powerful way.
  2. Reimplementing this function. This is very powerful, providing complete control; but only one subclass can be active at a time.
  3. Installing an event filter on QCoreApplication::instance(). Such an event filter is able to process all events for all widgets, so it is just as powerful as reimplementing notify(); furthermore, it is possible to have more than one application-global event filter. Global event filters even see mouse events for disabled widgets. Application event filters are only called for objects which live in the main thread.
  4. Reimplementing QObject::event() (as QWidget does). If you do this you get Tab key presses, and you get to see the events before any widget-specific event filters.
  5. Installing an event filter on the object. Such an event filter gets all the events, including Tab and Shift+Tab key press events, as long as they do not change the focus widget.
See also
QObject::event(), installEventFilter()

Reimplemented in QApplication::notify()

QString QCoreApplication::organizationDomain ( )
static

Returns the value of the property organizationDomain.

QString QCoreApplication::organizationName ( )
static

Returns the value of the property organizationName.

void QCoreApplication::postEvent ( QObject receiver,
QEvent event,
int  priority = Qt::NormalEventPriority 
)
static

Adds the given event with the object receiver as the receiver of the event, to an event queue and returns immediately. When control returns to the main event loop, all events that are stored in the queue will be sent using the notify() method.

The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been posted. It is not safe to access the event after it has been posted.

Events are sorted in descending priority order, i.e. events with a high priority are queued before events with a lower priority. The priority can be any integer value, i.e. between INT_MAX and INT_MIN, inclusive. Refer to Qt::EventPriority for more details. Events with equal priority will be processed in the order posted.

This method is thread-safe.

See also
sendEvent(), notify(), sendPostedEvents(), Qt::EventPriority
void QCoreApplication::processEvents ( QEventLoop::ProcessEventsFlags  flags,
int  maxtime 
)
static

Processes pending events for the calling thread for maxtime milliseconds or until there are no more events to process, whichever is shorter. You can call this function occasionally when your program is busy doing a long operation such as copying a file.

This method is thread-safe.

See also
exec(), QTimer, QEventLoop::processEvents()
void QCoreApplication::processEvents ( QEventLoop::ProcessEventsFlags  flags = QEventLoop::AllEvents)
static

Processes all pending events for the calling thread according to the specified flags until there are no more events to process. You can call this function occasionally when your program is busy performing a long operation such as copying a file.

In event you are running a local loop which calls this function continuously, without an event loop, the DeferredDelete events will not be processed. This can affect the behavior of widgets, e.g. QToolTip, that rely on DeferredDelete events to function properly. An alternative would be to call sendPostedEvents() from within that local loop.

This method is thread-safe.

See also
exec(), QTimer, QEventLoop::processEvents(), flush(), sendPostedEvents()
void QCoreApplication::quit ( )
slot

Instructs the application to exit with return code 0 (success). Equivalent to calling QCoreApplication::exit(0).

It is common to connect the QApplication::lastWindowClosed() signal to quit(). You may also want to connect other signals like QAbstractButton::clicked() or similar signals in QAction, QMenu, or QMenuBar to QApplication::lastWindowClosed().

QPushButton *quitButton = new QPushButton("Quit");
connect(quitButton, SIGNAL(clicked()), &app, SLOT(quit()));
See also
exit(), aboutToQuit(), QApplication::lastWindowClosed()
void QCoreApplication::removeLibraryPath ( const QString path)
static

Removes path from the library path list. If path is empty or not in the path list, the list is not changed.

See also
addLibraryPath(), libraryPaths(), setLibraryPaths()
void QCoreApplication::removeNativeEventFilter ( QAbstractNativeEventFilter filterObj)

Removes an event filterObj from this object. The request is ignored if such an event filter has not been installed. All event filters for this object are automatically removed when this object is destroyed.

It is always safe to remove an event filter even during event filter activation.

See also
installNativeEventFilter()
void QCoreApplication::removePostedEvents ( QObject receiver,
int  eventType = 0 
)
static

Removes all events of the given eventType that were posted using postEvent() for receiver. If receiver is null, the events of eventType are removed for all objects. If eventType is 0, all the events are removed for receiver.

The events are not dispatched, instead they are removed from the queue. You should never need to call this function. If you do call it, be aware that killing events may cause receiver to break one or more invariants.

This method is thread-safe.

void QCoreApplication::removeTranslator ( QTranslator translationFile)
static

Removes the translation file translationFile from the list of translation files used by this application. (It does not delete the translation file from the file system.)

See also
installTranslator(), translate(), QObject::tr()
bool QCoreApplication::sendEvent ( QObject receiver,
QEvent event 
)
inlinestatic

Sends the given event directly to receiver, using the notify() function. Returns the value that was returned from the event handler.

The event is not deleted when the event has been sent. The normal approach is to create the event on the stack as shown in this sample code.

QMouseEvent event(QEvent::MouseButtonPress, pos, 0, 0, 0);
QApplication::sendEvent(mainWindow, &event);
See also
postEvent(), notify()
void QCoreApplication::sendPostedEvents ( QObject receiver = nullptr,
int  event_type = 0 
)
static

Immediately dispatches all events which have been previously queued with QCoreApplication::postEvent() and which are for the object receiver and have the event type event_type.

Events from the window system are not dispatched by this function, but by processEvents().

If receiver is null the events of event_type are sent for all objects. If event_type is 0, all the events are sent for receiver.

Note
This method must be called from the same thread as its QObject parameter, receiver.
See also
flush(), postEvent()
void QCoreApplication::setApplicationName ( const QString application)
static

Sets the value of the property to application.

void QCoreApplication::setApplicationVersion ( const QString version)
static

Sets the value of the property to version.

void QCoreApplication::setAttribute ( Qt::ApplicationAttribute  attribute,
bool  on = true 
)
static

Sets the given attribute if on is true, otherwise clears the attribute.

One of the attributes that can be set with this method is Qt::Immediateness. CopperSpice will create a toplevel window immediately where as normally, resources for widgets are allocated on demand to improve efficiency and minimize resource usage. If it is important to minimize resource consumption, do not set this attribute.

See also
testAttribute()
void QCoreApplication::setLibraryPaths ( const QStringList paths)
static

Sets the list of directories to search when loading libraries to paths. All existing paths will be deleted and the path list will consist of the paths given in paths.

See also
libraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary
void QCoreApplication::setOrganizationDomain ( const QString orgDomain)
static

Sets the value of the property to orgDomain.

void QCoreApplication::setOrganizationName ( const QString orgName)
static

Sets the value of the property to orgName.

void QCoreApplication::setQuitLockEnabled ( bool  enabled)
static

Sets the value of the property to enabled.

void QCoreApplication::setSetuidAllowed ( bool  allow)
static

Allows the application to run setuid on UNIX platforms if allow is true.

If allow is false (which is the default) and CopperSpice detects the application is running with an effective user id different than the real user id, the application will be aborted when a QCoreApplication instance is created.

CopperSpice is not an appropriate solution for setuid programs due to its large attack surface. However some applications may be required to run in this manner for historical reasons. This flag will prevent CopperSpice from aborting the application when this is detected and must be set before a QCoreApplication instance is created.

It is strongly recommended not to enable this option since it introduces security risks.

See also
isSetuidAllowed()
bool QCoreApplication::startingUp ( )
static

Returns true if an application object has not been created yet, otherwise returns false.

See also
closingDown()
bool QCoreApplication::testAttribute ( Qt::ApplicationAttribute  attribute)
static

Returns true if attribute is set, otherwise returns false.

See also
setAttribute()
QString QCoreApplication::translate ( const char *  context,
const char *  text,
const char *  comment = nullptr,
std::optional< int >  numArg = std::optional<int>() 
)
static

Returns the translation text by querying the installed translation files. If none of the translation files contain a translation for text this method returns the text untranslated.

The translation files are searched starting with the most recently installed and then progressing to older files. The parameter context is typically a class name. The optional parameter comment is an identifying string which is used when the same text can be translated differently depending on the context. By default the value is nullptr.

If a value for numArg was passed it will be substituted for the %n in the translated string. This value is also used to choose the appropriate plural form in the translation. An example of the translated text (shown in English for readability) would be "1 file found" versus "5 files found".

Refer to Handle Plurals for additional information.

See also
QObject::tr(), QTranslator, installTranslator()
QString QCoreApplication::translate ( const QString context,
const QString text,
const QString comment = QString(),
std::optional< int >  numArg = std::optional<int>() 
)
static

The documentation for this overload is identical to the version of translate() which declares the first three parameters as "const char *".

void QCoreApplication::unixSignal ( int  signalId)
signal

This signal is emitted whenever a Unix signal is received by the application. The given signalId refers to which signal was received. Refer to the POSIX standard for a full list of signal ids.

Friends And Related Function Documentation

void qAddPostRoutine ( QtCleanUpFunction  ptr)
related

Adds a global routine which will be called from the QApplication destructor. This function is normally used to add cleanup routines for program wide functionality.

The function specified by ptr should take no arguments and return nothing.

static int *global_ptr = nullptr;
static void cleanup_ptr() {
delete [] global_ptr;
global_ptr = nullptr;
}
void init_ptr() {
global_ptr = new int[100]; // allocate data
qAddPostRoutine(cleanup_ptr); // delete later
}

For an application or module wide cleanup this function is often not suitable. For example, if the program is split into dynamically loaded modules, the relevant module may be unloaded long before the QApplication destructor is called.

For modules and libraries, using a reference-counted initialization manager or the parent-child deletion mechanism may be better. Here is an example of a private class that uses the parent-child mechanism to call a cleanup function at the right time.

class MyPrivateInitStuff : public QObject
{
CS_OBJECT(MyPrivateInitStuff)
public:
static MyPrivateInitStuff *initStuff(QObject *parent) {
if (! p) {
p = new MyPrivateInitStuff(parent);
}
return p;
}
~MyPrivateInitStuff() {
// cleanup goes here
}
private:
MyPrivateInitStuff(QObject *parent) : QObject(parent) {
// initialization goes here
}
MyPrivateInitStuff *p;
};
See also
qRemovePostRoutine()
void qRemovePostRoutine ( QtCleanUpFunction  ptr)
related

Removes the cleanup routine specified by ptr from the list of routines called by the QCoreApplication destructor. The routine must have been previously added to the list by a call to qAddPostRoutine(), otherwise this function has no effect.

See also
qAddPostRoutine()

Property Documentation

QCoreApplication::applicationName

This property holds the name of the current application. The property value is used by the QSettings default constructor.

See also
organizationName, organizationDomain, applicationVersion
PropertiesClass Methods
read applicationName
write setApplicationName
QCoreApplication::applicationVersion

This property holds the version of the current application.

See also
applicationName, organizationName, organizationDomain
PropertiesClass Methods
read applicationVersion
write setApplicationVersion
QCoreApplication::organizationDomain

This property holds the Internet domain of the organization that wrote the current application. The property value is used by the QSettings default constructor.

On Mac, QSettings uses organizationDomain() as the organization if it is not an empty string, otherwise it uses organizationName().

See also
organizationName, applicationName, applicationVersion
PropertiesClass Methods
read organizationDomain
write setOrganizationDomain
QCoreApplication::organizationName

This property holds the name of the organization who developed the current application. The property value is used by the QSettings default constructor.

On Mac OS X QSettings uses organizationDomain() as the organization if it is not an empty string, otherwise it uses organizationName().

See also
organizationDomain, applicationName
PropertiesClass Methods
read organizationName
write setOrganizationName
QCoreApplication::quitLockEnabled

This property holds whether the use of QEventLoopLocker can cause the application to shut down. The default is true.

PropertiesClass Methods
read isQuitLockEnabled
write setQuitLockEnabled