Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtCore.QCoreApplication Class Reference

The QCoreApplication class provides an event loop for console Qt applications. More...

Inheritance diagram for QtCore.QCoreApplication:
Collaboration diagram for QtCore.QCoreApplication:

Public Types

enum  Encoding { CodecForTr = 0, DefaultCodec = 0, UnicodeUTF8 = 1 }
  More...
 

Public Member Functions

override void CreateProxy ()
 
override bool OnEvent (QEvent arg1)
 
 
virtual bool Notify (QObject arg1, QEvent arg2)
 
 
new bool SetEventFilter (bool filter)
 
 
new void Dispose ()
 
- Public Member Functions inherited from QtCore.QObject
 QObject (QObject parent=null)
 
 
new bool BlockSignals (bool b)
 
 
new
System.Collections.Generic.List
< QObject
Children ()
 
 
new bool Connect (QObject sender, string signal, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection)
 
 
new void DeleteLater ()
 
 
new bool Disconnect (QObject receiver, string member=null)
 
 
new bool Disconnect (string signal=null, QObject receiver=null, string member=null)
 
 
new void DumpObjectInfo ()
 
 
new void DumpObjectTree ()
 
 
new
System.Collections.Generic.List
< QByteArray
DynamicPropertyNames ()
 
 
virtual bool EventFilter (QObject arg1, QEvent arg2)
 
 
new bool Inherits (string classname)
 
 
new void InstallEventFilter (QObject arg1)
 
 
new bool IsWidgetType ()
 
 
new void KillTimer (int id)
 
 
new object Property (string name)
 
 
new void RemoveEventFilter (QObject arg1)
 
 
new bool SetProperty (string name, object value)
 
 
new void SetUserData (uint id, QObjectUserData data)
 
new bool SignalsBlocked ()
 
 
new int StartTimer (int interval)
 
 
new QObjectUserData UserData (uint id)
 
new void Dispose ()
 
- Public Member Functions inherited from QtCore.Qt
delegate QTextStream FuncQTextStreamQTextStream (QTextStream qTextStream)
 
delegate string FuncStringQByteArray (QByteArray qByteArray)
 
delegate QByteArray FuncQByteArrayString (string @string)
 
delegate void ActionQtMsgTypeString (QtMsgType qtMsgType, string @string)
 
delegate QObject FuncQObject ()
 

Static Public Member Functions

static void AddLibraryPath (string arg1)
 
 
static string ApplicationDirPath ()
 
 
static string ApplicationFilePath ()
 
 
static long ApplicationPid ()
 
 
static int Argc ()
 
static
System.Collections.Generic.List
< string > 
Arguments ()
 
 
static Pointer< sbyte > Argv ()
 
static bool ClosingDown ()
 
 
static void Exit (int retcode=0)
 
 
static void Flush ()
 
 
static bool HasPendingEvents ()
 
 
static void InstallTranslator (QTranslator messageFile)
 
 
static QCoreApplication Instance ()
 
 
static void PostEvent (QObject receiver, QEvent @event)
 
 
static void PostEvent (QObject receiver, QEvent @event, int priority)
 
 
static void ProcessEvents (QEventLoop.ProcessEventsFlag flags=QEventLoop.ProcessEventsFlag.AllEvents)
 
 
static void ProcessEvents (QEventLoop.ProcessEventsFlag flags, int maxtime)
 
 
static void Quit ()
 
 
static void RemoveLibraryPath (string arg1)
 
 
static void RemovePostedEvents (QObject receiver)
 
 
static void RemovePostedEvents (QObject receiver, int eventType)
 
 
static void RemoveTranslator (QTranslator messageFile)
 
 
static bool SendEvent (QObject receiver, QEvent @event)
 
 
static void SendPostedEvents ()
 
 
static void SendPostedEvents (QObject receiver, int event_type)
 
 
static void SetAttribute (Qt.ApplicationAttribute attribute, bool on=true)
 
 
static bool StartingUp ()
 
 
static bool TestAttribute (Qt.ApplicationAttribute attribute)
 
 
static string Tr (string s, string c=null)
 
static string Tr (string s, string c, int n)
 
static string TrUtf8 (string s, string c=null)
 
static string TrUtf8 (string s, string c, int n)
 
static string Translate (string context, string key, string disambiguation=null, QCoreApplication.Encoding encoding=QCoreApplication.Encoding.CodecForTr)
 
 
static string Translate (string context, string key, string disambiguation, QCoreApplication.Encoding encoding, int n)
 
 
- Static Public Member Functions inherited from QtCore.QObject
static bool Connect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod method, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection)
 
 
static bool Connect (QObject sender, string signal, QObject receiver, string member, Qt.ConnectionType arg5=Qt.ConnectionType.AutoConnection)
 
 
static bool Disconnect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod member)
 
 
static bool Disconnect (QObject sender, string signal, QObject receiver, string member)
 
 
static uint RegisterUserData ()
 
static string Tr (string s, string c=null)
 
 
static string Tr (string s, string c, int n)
 
 
static string TrUtf8 (string s, string c=null)
 
 
static string TrUtf8 (string s, string c, int n)
 
 
- Static Public Member Functions inherited from QtCore.Qt
static QDataStream Write (QDataStream s, object p)
 
static QDataStream Write (QDataStream arg1, QSizeF arg2)
 
static QTextStream Write (QTextStream s, Qt.FuncQTextStreamQTextStream f)
 
static QDataStream Write (QDataStream arg1, QPoint arg2)
 
static QDataStream Write (QDataStream arg1, QLineF arg2)
 
static QDataStream Write (QDataStream arg1, QPointF arg2)
 
static QDataStream Write (QDataStream arg1, QChar arg2)
 
static QDataStream Write (QDataStream arg1, QByteArray arg2)
 
static QDataStream Write (QDataStream arg1, QEasingCurve arg2)
 
static QDataStream Write (QDataStream arg1, QRectF arg2)
 
static QDataStream Write (QDataStream arg1, QDateTime arg2)
 
static QDataStream Write (QDataStream arg1, QUrl arg2)
 
static QDataStream Write (QDataStream arg1, QTime arg2)
 
static QDataStream Write (QDataStream arg1, QLocale arg2)
 
static QDataStream Write (QDataStream arg1, QBitArray arg2)
 
static QDataStream Write (QDataStream arg1, QUuid arg2)
 
static QDataStream Write (QDataStream arg1, QLine arg2)
 
static QDataStream Write (QDataStream arg1, QDate arg2)
 
static QDataStream Write (QDataStream @out, QRegExp regExp)
 
static QDataStream Write (QDataStream arg1, QRect arg2)
 
static QDataStream Write (QDataStream arg1, QSize arg2)
 
static QDataStream Write (QDataStream s, QVariant.Type p)
 
static QDataStream Write (QDataStream arg1, string arg2)
 
static QDataStream Write (QDataStream @out, System.Collections.Generic.List< string > list)
 
static QDataStream Read (QDataStream arg1, QChar arg2)
 
static QDataStream Read (QDataStream arg1, QLocale arg2)
 
static QDataStream Read (QDataStream arg1, QRect arg2)
 
static QDataStream Read (QDataStream arg1, QEasingCurve arg2)
 
static QDataStream Read (QDataStream arg1, QDate arg2)
 
static QDataStream Read (QDataStream arg1, QUrl arg2)
 
static QDataStream Read (QDataStream arg1, QUuid arg2)
 
static QTextStream Read (QTextStream s, Qt.FuncQTextStreamQTextStream f)
 
static QDataStream Read (QDataStream arg1, QLineF arg2)
 
static QDataStream Read (QDataStream arg1, QRectF arg2)
 
static QDataStream Read (QDataStream arg1, QPointF arg2)
 
static QDataStream Read (QDataStream arg1, QLine arg2)
 
static QDataStream Read (QDataStream arg1, QBitArray arg2)
 
static QDataStream Read (QDataStream arg1, QSize arg2)
 
static QDataStream Read (QDataStream arg1, QDateTime arg2)
 
static QDataStream Read (QDataStream arg1, QTime arg2)
 
static QDataStream Read (QDataStream arg1, QPoint arg2)
 
static QDataStream Read (QDataStream @in, QRegExp regExp)
 
static QDataStream Read (QDataStream s, object p)
 
static QDataStream Read (QDataStream arg1, QByteArray arg2)
 
static QDataStream Read (QDataStream arg1, QSizeF arg2)
 
static QDataStream Read (QDataStream arg1, string arg2)
 
static QDataStream Read (QDataStream s, QVariant.Type p)
 
static QDataStream Read (QDataStream @in, System.Collections.Generic.List< string > list)
 
static double qAcos (double v)
 
static void qAddPostRoutine (System.Action arg1)
 
static string qAppName ()
 
static double qAsin (double v)
 
static double qAtan (double v)
 
static double qAtan2 (double x, double y)
 
static void qBadAlloc ()
 
static int qCeil (double v)
 
static ushort qChecksum (string s, uint len)
 
static QByteArray qCompress (QByteArray data)
 
static QByteArray qCompress (QByteArray data, int compressionLevel=-1)
 
static QByteArray qCompress (Pointer< byte > data, int nbytes)
 
static QByteArray qCompress (Pointer< byte > data, int nbytes, int compressionLevel=-1)
 
static double qCos (double v)
 
static double qExp (double v)
 
static double qFabs (double v)
 
static double qFastCos (double x)
 
static double qFastSin (double x)
 
static string qFlagLocation (string method)
 
static int qFloor (double v)
 
static bool qFuzzyCompare (double p1, double p2)
 
static bool qFuzzyCompare (float p1, float p2)
 
static bool qFuzzyIsNull (double d)
 
static bool qFuzzyIsNull (float f)
 
static uint qHash (QBitArray key)
 
static uint qHash (QChar key)
 
static uint qHash (QStringRef key)
 
static uint qHash (QUrl url)
 
static uint qHash (QPersistentModelIndex index)
 
static uint qHash (QByteArray key)
 
static uint qHash (QModelIndex index)
 
static uint qHash (uint key)
 
static uint qHash (sbyte key)
 
static uint qHash (byte key)
 
static uint qHash (short key)
 
static uint qHash (NativeLong key)
 
static uint qHash (ushort key)
 
static uint qHash (long key)
 
static uint qHash (ulong key)
 
static uint qHash (int key)
 
static uint qHash (string key)
 
static uint qHash (NativeULong key)
 
static double qInf ()
 
static Qt.ActionQtMsgTypeString qInstallMsgHandler (Qt.ActionQtMsgTypeString arg1)
 
static int qIntCast (float f)
 
static int qIntCast (double f)
 
static bool qIsFinite (double d)
 
static bool qIsFinite (float f)
 
static bool qIsInf (float f)
 
static bool qIsInf (double d)
 
static bool qIsNaN (float f)
 
static bool qIsNaN (double d)
 
static bool qIsNull (float f)
 
static bool qIsNull (double d)
 
static double qLn (double v)
 
static double qPow (double x, double y)
 
static double qQNaN ()
 
static void qRegisterStaticPluginInstanceFunction (Qt.FuncQObject function)
 
static void qRemovePostRoutine (System.Action arg1)
 
static int qRound (double d)
 
static long qRound64 (double d)
 
static double qSNaN ()
 
static bool qSharedBuild ()
 
static double qSin (double v)
 
static double qSqrt (double v)
 
static bool qStringComparisonHelper (QStringRef s1, string s2)
 
static double qTan (double v)
 
static QByteArray qUncompress (QByteArray data)
 
static QByteArray qUncompress (Pointer< byte > data, int nbytes)
 
static string qVersion ()
 
static void Qbswap_helper (Pointer< byte > src, Pointer< byte > dest, int size)
 
static QByteArray Qgetenv (string varName)
 
static bool Qputenv (string varName, QByteArray value)
 
static int Qrand ()
 
static void Qsrand (uint seed)
 
static int Qstrcmp (QByteArray str1, QByteArray str2)
 
static int Qstrcmp (QByteArray str1, string str2)
 
static int Qstrcmp (string str1, QByteArray str2)
 
static int Qstrcmp (string str1, string str2)
 
static Pointer< sbyte > Qstrcpy (Pointer< sbyte > dst, string src)
 
static Pointer< sbyte > Qstrdup (string arg1)
 
static int Qstricmp (string arg1, string arg2)
 
static uint Qstrlen (string str)
 
static int Qstrncmp (string str1, string str2, uint len)
 
static Pointer< sbyte > Qstrncpy (Pointer< sbyte > dst, string src, uint len)
 
static int Qstrnicmp (string arg1, string arg2, uint len)
 
static uint Qstrnlen (string str, uint maxlen)
 
static string QtTrId (string id, int n=-1)
 

Protected Member Functions

 QCoreApplication (System.Type dummy)
 
new void OnAboutToQuit ()
 
 
new void OnUnixSignal (int arg1)
 
- Protected Member Functions inherited from QtCore.QObject
 QObject (System.Type dummy)
 
virtual void OnChildEvent (QChildEvent arg1)
 
 
virtual void ConnectNotify (string signal)
 
 
virtual void OnCustomEvent (QEvent arg1)
 
 
new void OnDestroyed (QObject arg1=null)
 
 
virtual void DisconnectNotify (string signal)
 
 
new int Receivers (string signal)
 
 
new QObject Sender ()
 
 
new int SenderSignalIndex ()
 
 
virtual void OnTimerEvent (QTimerEvent arg1)
 
 

Properties

Slot AboutToQuit
 
 
Slot< System.Int32 > UnixSignal
 
static
System.Collections.Generic.List
< string > 
LibraryPaths [get, set]
 
 
new string ApplicationName [get, set]
 
 
new string ApplicationVersion [get, set]
 
 
new string OrganizationName [get, set]
 
 
new string OrganizationDomain [get, set]
 
 
static new QMetaObject StaticMetaObject [get]
 
new IQCoreApplicationSignals Emit [get]
 
- Properties inherited from QtCore.QObject
virtual EventHandler
< QEventArgs< QChildEvent > > 
ChildEvent
 
 
virtual EventHandler
< QEventArgs< QEvent > > 
CustomEvent
 
 
virtual EventHandler
< QEventArgs< QEvent > > 
Event
 
 
virtual EventHandler
< QEventArgs< QTimerEvent > > 
TimerEvent
 
 
Slot< QObjectDestroyedQObject
 
Slot Destroyed
 
 
new QObject Parent [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 
new string ObjectName [get, set]
 
 
static new QMetaObject StaticMetaObject [get]
 
 
static new QMetaObject StaticQtMetaObject [get]
 
new IQObjectSignals Emit [get]
 

Additional Inherited Members

- Protected Attributes inherited from QtCore.QObject
object Q_EMIT = null
 
SmokeInvocation interceptor
 
readonly List< QEventHandler > eventFilters = new List<QEventHandler>()
 

Detailed Description

The QCoreApplication class provides an event loop for console Qt applications.

This class is used by non-GUI applications to provide their event loop. For non-GUI application that uses Qt, there should be exactly one QCoreApplication object. For GUI applications, see QApplication.

QCoreApplication contains the main event loop, where all events from the operating system (e.g., timer and network events) and other sources are processed and dispatched. It also handles the application's initialization and finalization, as well as system-wide and application-wide settings.

The 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, we recommend that you create a QCoreApplication or a QApplication object in your main() function as early as possible. exec() will not return until the event loop exits; e.g., when quit() is called.

Several static convenience functions are also provided. The QCoreApplication object is available from instance(). Events can be sent or posted using sendEvent(), postEvent(), and sendPostedEvents(). Pending events can be removed with removePostedEvents() or flushed with flush().

The class provides a quit() slot and an aboutToQuit() signal.

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(). The QObject::tr() and QObject::trUtf8() functions are implemented in terms of translate().

Accessing Command Line Arguments

The command line arguments which are passed to QCoreApplication's constructor should be accessed using the arguments() function. Note that some arguments supplied by the user may have been processed and removed by QCoreApplication.

In cases where command line arguments need to be obtained using the argv() function, you must convert them from the local string encoding using QString::fromLocal8Bit().

Locale Settings

On Unix/Linux Qt is configured to use the system locale settings by default. This can cause a conflict when using POSIX functions, for instance, when converting between data types such as floats and strings, since the notation may differ between locales. To get around this problem, call the POSIX function setlocale(LC_NUMERIC,"C") right after initializing QApplication or QCoreApplication to reset the locale that is used for number formatting to "C"-locale.

See also QApplication, QAbstractEventDispatcher, QEventLoop, Semaphores Example, and Wait Conditions Example.

Member Enumeration Documentation

This enum type defines the 8-bit encoding of character string arguments to translate():

See also QObject::tr(), QObject::trUtf8(), and QString::fromUtf8().

Enumerator:
CodecForTr 

The encoding specified by QTextCodec::codecForTr() (Latin-1 if none has been set).

DefaultCodec 

(Obsolete) Use CodecForTr instead.

UnicodeUTF8 

UTF-8.

Constructor & Destructor Documentation

QtCore.QCoreApplication.QCoreApplication ( System.Type  dummy)
protected

Member Function Documentation

static void QtCore.QCoreApplication.AddLibraryPath ( string  arg1)
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 Qt was installed.

In Symbian this function is only useful for adding paths for finding Qt extension plugin stubs, since the OS can only load libraries from the /sys/bin directory.

See also removeLibraryPath(), libraryPaths(), and setLibraryPaths().

static string QtCore.QCoreApplication.ApplicationDirPath ( )
static

Returns the directory that contains the application executable.

For example, if you have installed Qt in the C:\Trolltech\Qt directory, and you run the regexp example, this function will return "C:/Trolltech/Qt/examples/tools/regexp".

On Mac OS X this will point to the directory actually containing the executable, which may be inside of an application bundle (if the application is bundled).

Warning: On Linux, this function 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 function also assumes that the current directory has not been changed by the application.

In Symbian this function will return the application private directory, not the path to executable itself, as those are always in /sys/bin. If the application is in a read only drive, i.e. ROM, then the private path on the system drive will be returned.

See also applicationFilePath().

static string QtCore.QCoreApplication.ApplicationFilePath ( )
static

Returns the file path of the application executable.

For example, if you have installed Qt in the /usr/local/qt directory, and you run the regexp example, this function will return "/usr/local/qt/examples/tools/regexp/regexp".

Warning: On Linux, this function 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 function also assumes that the current directory has not been changed by the application.

See also applicationDirPath().

static long QtCore.QCoreApplication.ApplicationPid ( )
static

Returns the current process ID for the application.

This function was introduced in Qt 4.4.

static int QtCore.QCoreApplication.Argc ( )
static
static System.Collections.Generic.List<string> QtCore.QCoreApplication.Arguments ( )
static

Returns the list of command-line arguments.

Usually arguments().at(0) is the program name, arguments().at(1) is the first argument, and arguments().last() is the last argument. See the note below about Windows.

Calling this function is slow - you should store the result in a variable when parsing the command line.

Warning: On Unix, this list is built from the argc and argv parameters passed to the constructor in the main() function. The string-data in argv is interpreted using QString::fromLocal8Bit(); hence it is not possible to pass, for example, Japanese command line arguments on a system that runs in a Latin1 locale. Most modern Unix systems do not have this limitation, as they are Unicode-based.

On NT-based Windows, this limitation does not apply either. On Windows, the arguments() are not built from the contents of argv/argc, as the content does not support Unicode. Instead, the arguments() are constructed from the return value of GetCommandLine(). As a result of this, the string given by arguments().at(0) might not be the program name on Windows, depending on how the application was started.

For Symbian applications started with RApaLsSession::StartApp one can specify arguments using CApaCommandLine::SetTailEndL function. Such arguments are only available via this method; they will not be passed to main function. Also note that only 8-bit string data set with CApaCommandLine::SetTailEndL is supported by this function.

This function was introduced in Qt 4.1.

See also applicationFilePath().

static Pointer<sbyte> QtCore.QCoreApplication.Argv ( )
static
static bool QtCore.QCoreApplication.ClosingDown ( )
static

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

See also startingUp().

override void QtCore.QCoreApplication.CreateProxy ( )
virtual

Reimplemented from QtCore.QObject.

Reimplemented in QtGui.QApplication.

new void QtCore.QCoreApplication.Dispose ( )
static void QtCore.QCoreApplication.Exit ( int  retcode = 0)
static

Tells the application to exit with a return code.

After this function has been called, the application leaves the main event loop and returns from the call to exec(). The exec() function returns returnCode. If the event loop is not running, this function does nothing.

By convention, a returnCode of 0 means success, and any non-zero value indicates an error.

Note that unlike the C library function of the same name, this function does return to the caller – it is event processing that stops.

See also quit() and exec().

static void QtCore.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 function.

See also sendPostedEvents().

static bool QtCore.QCoreApplication.HasPendingEvents ( )
static

This function returns true if there are pending events; otherwise returns false. Pending events can be either from the window system or posted events using postEvent().

See also QAbstractEventDispatcher::hasPendingEvents().

static void QtCore.QCoreApplication.InstallTranslator ( QTranslator  messageFile)
static

Adds the translation file translationFile to the list of translation files to be used for translations.

Multiple translation files can be installed. Translations are searched for in the reverse order in which they were installed, so the most recently installed translation file is searched first and the first translation file installed is searched last. The search stops as soon as a translation containing a matching string is found.

Installing or removing a QTranslator, or changing an installed QTranslator generates a LanguageChange event for the QCoreApplication instance. A QApplication instance will propagate the event to all toplevel windows, where a reimplementation of changeEvent can re-translate the user interface by passing user-visible strings via the tr() function to the respective property setters. User-interface classes generated by Qt Designer provide a retranslateUi() function that can be called.

See also removeTranslator(), translate(), QTranslator::load(), and Dynamic Translation.

static QCoreApplication QtCore.QCoreApplication.Instance ( )
static

Returns a pointer to the application's QCoreApplication (or QApplication) instance.

If no instance has been allocated, null is returned.

virtual bool QtCore.QCoreApplication.Notify ( QObject  arg1,
QEvent  arg2 
)
virtual

Sends event to receiver: receiver->event(event). Returns the value that is returned from the receiver's event handler. Note that this function 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:

Reimplementing paintEvent(), mousePressEvent() and so on. This is the commonest, easiest and least powerful way.

Reimplementing this function. This is very powerful, providing complete control; but only one subclass can be active at a time.

Installing an event filter on QCoreApplication::instance(). Such an event filter is able to process all events for all widgets, so it's just as powerful as reimplementing notify(); furthermore, it's possible to have more than one application-global event filter. Global event filters even see mouse events for disabled widgets. Note that application event filters are only called for objects that live in the main thread.

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.

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() and installEventFilter().

Reimplemented in QtGui.QApplication.

new void QtCore.QCoreApplication.OnAboutToQuit ( )
protected

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. Note that no user interaction is possible in this state.

See also quit().

override bool QtCore.QCoreApplication.OnEvent ( QEvent  arg1)
virtual

Reimplemented from QObject::event().

Reimplemented from QtCore.QObject.

Reimplemented in QtGui.QApplication.

new void QtCore.QCoreApplication.OnUnixSignal ( int  arg1)
protected
static void QtCore.QCoreApplication.PostEvent ( QObject  receiver,
QEvent event 
)
static

Adds the event event, with the object receiver as the receiver of the event, to an event queue and returns immediately.

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.

When control returns to the main event loop, all events that are stored in the queue will be sent using the notify() function.

Events are processed in the order posted. For more control over the processing order, use the postEvent() overload below, which takes a priority argument. This function posts all event with a Qt::NormalEventPriority.

Note: This function is thread-safe.

See also sendEvent(), notify(), and sendPostedEvents().

static void QtCore.QCoreApplication.PostEvent ( QObject  receiver,
QEvent event,
int  priority 
)
static

This function overloads postEvent().

Adds the event event, with the object receiver as the receiver of the event, to an event queue and returns immediately.

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.

When control returns to the main event loop, all events that are stored in the queue will be sent using the notify() function.

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; see Qt::EventPriority for more details. Events with equal priority will be processed in the order posted.

Note: This function is thread-safe.

This function was introduced in Qt 4.3.

See also sendEvent(), notify(), sendPostedEvents(), and Qt::EventPriority.

static void QtCore.QCoreApplication.ProcessEvents ( QEventLoop.ProcessEventsFlag  flags = QEventLoop.ProcessEventsFlag.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 (e.g. 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 behaviour 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.

Calling this function processes events only for the calling thread.

Note: This function is thread-safe.

See also exec(), QTimer, QEventLoop::processEvents(), flush(), and sendPostedEvents().

static void QtCore.QCoreApplication.ProcessEvents ( QEventLoop.ProcessEventsFlag  flags,
int  maxtime 
)
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 (e.g. 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 behaviour 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.

Calling this function processes events only for the calling thread.

Note: This function is thread-safe.

See also exec(), QTimer, QEventLoop::processEvents(), flush(), and sendPostedEvents().

static void QtCore.QCoreApplication.Quit ( )
static

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

It's common to connect the QApplication::lastWindowClosed() signal to quit(), and you also often connect e.g. QAbstractButton::clicked() or signals in QAction, QMenu, or QMenuBar to it.

Example:

QPushButton *quitButton = new QPushButton("Quit");

connect(quitButton, SIGNAL(clicked()), &app, SLOT(quit()));

See also exit(), aboutToQuit(), and QApplication::lastWindowClosed().

static void QtCore.QCoreApplication.RemoveLibraryPath ( string  arg1)
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(), and setLibraryPaths().

static void QtCore.QCoreApplication.RemovePostedEvents ( QObject  receiver)
static

Removes all events posted using postEvent() 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.

Note: This function is thread-safe.

static void QtCore.QCoreApplication.RemovePostedEvents ( QObject  receiver,
int  eventType 
)
static

This function overloads removePostedEvents().

Removes all events of the given eventType that were posted using postEvent() 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.

If receiver is null, the events of eventType are removed for all objects. If eventType is 0, all the events are removed for receiver.

Note: This function is thread-safe.

This function was introduced in Qt 4.3.

static void QtCore.QCoreApplication.RemoveTranslator ( QTranslator  messageFile)
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(), and QObject::tr().

static bool QtCore.QCoreApplication.SendEvent ( QObject  receiver,
QEvent event 
)
static

Sends event event directly to receiver 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, for example:

QMouseEvent event(QEvent::MouseButtonPress, pos, 0, 0, 0);

QApplication::sendEvent(mainWindow, &event);

See also postEvent() and notify().

static void QtCore.QCoreApplication.SendPostedEvents ( )
static

This function overloads sendPostedEvents().

Dispatches all posted events, i.e. empties the event queue.

static void QtCore.QCoreApplication.SendPostedEvents ( QObject  receiver,
int  event_type 
)
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() and postEvent().

static void QtCore.QCoreApplication.SetAttribute ( Qt.ApplicationAttribute  attribute,
bool  on = true 
)
static

Sets the attribute attribute if on is true; otherwise clears the attribute.

One of the attributes that can be set with this method is Qt::AA_ImmediateWidgetCreation. It tells Qt to create toplevel windows immediately. Normally, resources for widgets are allocated on demand to improve efficiency and minimize resource usage. Therefore, if it is important to minimize resource consumption, do not set this attribute.

See also testAttribute().

new bool QtCore.QCoreApplication.SetEventFilter ( bool  filter)

Replaces the event filter function for the QCoreApplication with filter and returns the pointer to the replaced event filter function. Only the current event filter function is called. If you want to use both filter functions, save the replaced EventFilter in a place where yours can call it.

The event filter function set here is called for all messages received by all threads meant for all Qt objects. It is not called for messages that are not meant for Qt objects.

The event filter function should return true if the message should be filtered, (i.e. stopped). It should return false to allow processing the message to continue.

By default, no event filter function is set (i.e., this function returns a null EventFilter the first time it is called).

Note: The filter function set here receives native messages, i.e. MSG or XEvent structs, that are going to Qt objects. It is called by QCoreApplication::filterEvent(). If the filter function returns false to indicate the message should be processed further, the native message can then be translated into a QEvent and handled by the standard Qt event filering, e.g. QObject::installEventFilter().

Note: The filter function set here is different form the filter function set via QAbstractEventDispatcher::setEventFilter(), which gets all messages received by its thread, even messages meant for objects that are not handled by Qt.

See also QObject::installEventFilter() and QAbstractEventDispatcher::setEventFilter().

static bool QtCore.QCoreApplication.StartingUp ( )
static

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

See also closingDown().

static bool QtCore.QCoreApplication.TestAttribute ( Qt.ApplicationAttribute  attribute)
static

Returns true if attribute attribute is set; otherwise returns false.

See also setAttribute().

static string QtCore.QCoreApplication.Tr ( string  s,
string  c = null 
)
static
static string QtCore.QCoreApplication.Tr ( string  s,
string  c,
int  n 
)
static
static string QtCore.QCoreApplication.Translate ( string  context,
string  key,
string  disambiguation = null,
QCoreApplication.Encoding  encoding = QCoreApplication.Encoding.CodecForTr 
)
static

This function overloads translate().

static string QtCore.QCoreApplication.Translate ( string  context,
string  key,
string  disambiguation,
QCoreApplication.Encoding  encoding,
int  n 
)
static

Returns the translation text for sourceText, by querying the installed translation files. The translation files are searched from the most recently installed file back to the first installed file.

QObject::tr() and QObject::trUtf8() provide this functionality more conveniently.

context is typically a class name (e.g., "MyDialog") and sourceText is either English text or a short identifying text.

disambiguation is an identifying string, for when the same sourceText is used in different roles within the same context. By default, it is null.

See the QTranslator and QObject::tr() documentation for more information about contexts, disambiguations and comments.

encoding indicates the 8-bit encoding of character strings.

n is used in conjunction with n to support plural forms. See QObject::tr() for details.

If none of the translation files contain a translation for sourceText in context, this function returns a QString equivalent of sourceText. The encoding of sourceText is specified by encoding; it defaults to CodecForTr.

This function is not virtual. You can use alternative translation techniques by subclassing QTranslator.

Warning: This method is reentrant only if all translators are installed before calling this method. Installing or removing translators while performing translations is not supported. Doing so will most likely result in crashes or other undesirable behavior.

Note: This function is reentrant.

This function was introduced in Qt 4.5.

See also QObject::tr(), installTranslator(), and QTextCodec::codecForTr().

static string QtCore.QCoreApplication.TrUtf8 ( string  s,
string  c = null 
)
static
static string QtCore.QCoreApplication.TrUtf8 ( string  s,
string  c,
int  n 
)
static

Property Documentation

Slot QtCore.QCoreApplication.AboutToQuit
addremove

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. Note that no user interaction is possible in this state.

See also quit().

new string QtCore.QCoreApplication.ApplicationName
getset

This property holds the name of this application.

The value is used by the QSettings class when it is constructed using the empty constructor. This saves having to repeat this information each time a QSettings object is created.

new string QtCore.QCoreApplication.ApplicationVersion
getset

This property holds the version of this application.

This property was introduced in Qt 4.4.

new IQCoreApplicationSignals QtCore.QCoreApplication.Emit
getprotected
System.Collections.Generic.List<string> QtCore.QCoreApplication.LibraryPaths
staticgetset

Returns a list of paths that the application will search when dynamically loading libraries.

Qt provides default library paths, but they can also be set using a qt.conf file. Paths specified in this file will override default values.

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 Qt was installed). The directory of the application executable (NOT the working directory) is always added, as well as the colon separated entries of the QT_PLUGIN_PATH environment variable.

If you want to iterate over the list, you can use the foreach pseudo-keyword:

foreach (const QString &path, app.libraryPaths())

do_something(path);

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.

In Symbian this function is only useful for setting paths for finding Qt extension plugin stubs, since the OS can only load libraries from the /sys/bin directory.

new string QtCore.QCoreApplication.OrganizationDomain
getset

This property holds the Internet domain of the organization that wrote this application.

The value is used by the QSettings class when it is constructed using the empty constructor. This saves having to repeat this information each time a QSettings object is created.

On Mac, QSettings uses organizationDomain() as the organization if it's not an empty string; otherwise it uses organizationName(). On all other platforms, QSettings uses organizationName() as the organization.

new string QtCore.QCoreApplication.OrganizationName
getset

This property holds the name of the organization that wrote this application.

The value is used by the QSettings class when it is constructed using the empty constructor. This saves having to repeat this information each time a QSettings object is created.

On Mac, QSettings uses organizationDomain() as the organization if it's not an empty string; otherwise it uses organizationName(). On all other platforms, QSettings uses organizationName() as the organization.

new QMetaObject QtCore.QCoreApplication.StaticMetaObject
staticget
Slot<System.Int32> QtCore.QCoreApplication.UnixSignal
addremove