#include <qcoreapplication.h>
Inheritance diagram for QCoreApplication:


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 command line arguments which QCoreApplication's constructor should be called with are accessible using arguments(). The event loop is started with a call to exec(). Long running operations can call processEvents() to keep the application responsive.
Some Qt classes, such as QString, can be used without a QCoreApplication object. However, in general, we recommend that you create a QCoreApplication or a QApplication object in your main() function as early as possible.
An application has an applicationDirPath() and an applicationFilePath(). 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().
The class provides a quit() slot and an aboutToQuit() signal.
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(). Library paths (see QLibrary) can be retrieved with libraryPaths() and manipulated by setLibraryPaths(), addLibraryPath(), and removeLibraryPath().
Definition at line 49 of file qcoreapplication.h.
Public Types | |
| enum | Encoding |
| typedef bool(*) | EventFilter (void *message, long *result) |
Public Slots | |
| static void | quit () |
Signals | |
| void | aboutToQuit () |
| void | unixSignal (int) |
Public Member Functions | |
| QCoreApplication (int &argc, char **argv) | |
| ~QCoreApplication () | |
| virtual bool | notify (QObject *, QEvent *) |
| EventFilter | setEventFilter (EventFilter filter) |
| bool | filterEvent (void *message, long *result) |
Static Public Member Functions | |
| static QStringList | arguments () |
| static void | setAttribute (Qt::ApplicationAttribute attribute, bool on=true) |
| static bool | testAttribute (Qt::ApplicationAttribute attribute) |
| static void | setOrganizationDomain (const QString &orgDomain) |
| static QString | organizationDomain () |
| static void | setOrganizationName (const QString &orgName) |
| static QString | organizationName () |
| static void | setApplicationName (const QString &application) |
| static QString | applicationName () |
| static QCoreApplication * | instance () |
| static int | exec () |
| static void | processEvents (QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents) |
| static void | processEvents (QEventLoop::ProcessEventsFlags flags, int maxtime) |
| static void | exit (int retcode=0) |
| static bool | sendEvent (QObject *receiver, QEvent *event) |
| static void | postEvent (QObject *receiver, QEvent *event) |
| static void | sendPostedEvents (QObject *receiver, int event_type) |
| static void | sendPostedEvents () |
| static void | removePostedEvents (QObject *receiver) |
| static bool | hasPendingEvents () |
| static bool | startingUp () |
| static bool | closingDown () |
| static QString | applicationDirPath () |
| static QString | applicationFilePath () |
| static void | setLibraryPaths (const QStringList &) |
| static QStringList | libraryPaths () |
| static void | addLibraryPath (const QString &) |
| static void | removeLibraryPath (const QString &) |
| static void | installTranslator (QTranslator *messageFile) |
| static void | removeTranslator (QTranslator *messageFile) |
| static QString | translate (const char *context, const char *key, const char *comment=0, Encoding encoding=CodecForTr) |
| static QString | translate (const char *context, const char *key, const char *comment, Encoding encoding, int n) |
| static void | flush () |
Protected Member Functions | |
| bool | event (QEvent *) |
| virtual bool | compressEvent (QEvent *, QObject *receiver, QPostEventList *) |
| QCoreApplication (QCoreApplicationPrivate &p) | |
Private Member Functions | |
| void | init () |
Static Private Member Functions | |
| static bool | sendSpontaneousEvent (QObject *receiver, QEvent *event) |
Static Private Attributes | |
| static QCoreApplication * | self |
Friends | |
| class | QEventDispatcherUNIXPrivate |
| class | QApplication |
| class | QApplicationPrivate |
| class | QETWidget |
| class | Q3AccelManager |
| class | QShortcutMap |
| class | QWidget |
| class | QWidgetPrivate |
| bool | qt_sendSpontaneousEvent (QObject *, QEvent *) |
| Q_CORE_EXPORT QString | qAppName () |
Related Functions | |
| (Note that these are not member functions.) | |
| void | qAddPostRoutine (QtCleanUpFunction ptr) |
A function with the following signature that can be used as an event filter:
bool myEventFilter(void *message, long *result);
Definition at line 144 of file qcoreapplication.h.
This enum type defines the 8-bit encoding of character string arguments to translate():
CodecForTr The encoding specified by QTextCodec::codecForTr() (Latin-1 if none has been set). UnicodeUTF8 UTF-8. DefaultCodec (Obsolete) Use CodecForTr instead.
Definition at line 110 of file qcoreapplication.h.
00110 { CodecForTr, UnicodeUTF8, DefaultCodec = CodecForTr };
| QCoreApplication::QCoreApplication | ( | int & | argc, | |
| char ** | argv | |||
| ) |
Constructs a Qt kernel application. Kernel applications are applications without a graphical user interface. These type of applications are used at the console or as server processes.
The argc and argv arguments are processed by the application, and made available in a more convenient form by the arguments() function.
Definition at line 406 of file qcoreapplication.cpp.
References QCoreApplicationPrivate::eventDispatcher, init(), and QAbstractEventDispatcher::startingUp().
00407 : QObject(*new QCoreApplicationPrivate(argc, argv)) 00408 { 00409 init(); 00410 QCoreApplicationPrivate::eventDispatcher->startingUp(); 00411 }
Here is the call graph for this function:

| QCoreApplication::~QCoreApplication | ( | ) |
Destroys the QCoreApplication object.
Definition at line 476 of file qcoreapplication.cpp.
References QThread::cleanup(), QAbstractEventDispatcher::closingDown(), QCoreApplicationPrivate::eventDispatcher, QCoreApplicationPrivate::is_app_closing, QCoreApplicationPrivate::is_app_running, and qt_call_post_routines().
00477 { 00478 qt_call_post_routines(); 00479 00480 self = 0; 00481 QCoreApplicationPrivate::is_app_closing = true; 00482 QCoreApplicationPrivate::is_app_running = false; 00483 00484 #ifndef QT_NO_THREAD 00485 QThread::cleanup(); 00486 #endif 00487 00488 d_func()->threadData->eventDispatcher = 0; 00489 if (QCoreApplicationPrivate::eventDispatcher) 00490 QCoreApplicationPrivate::eventDispatcher->closingDown(); 00491 QCoreApplicationPrivate::eventDispatcher = 0; 00492 }
Here is the call graph for this function:

| QCoreApplication::QCoreApplication | ( | QCoreApplicationPrivate & | p | ) | [protected] |
| QStringList QCoreApplication::arguments | ( | ) | [static] |
arguments().at(0) is the program name, arguments().at(1) is the first argument, and arguments().last() is the last argument.
Calling this function is slow - you should store the result in a variable when parsing the command line.
Definition at line 1582 of file qcoreapplication.cpp.
References a, QList< T >::at(), QList< T >::count(), QString::fromLocal8Bit(), QString::fromUtf16(), qWarning(), self, QByteArray::startsWith(), stripped(), and QString::toLatin1().
Referenced by main(), and TextEdit::TextEdit().
01583 { 01584 QStringList list; 01585 01586 if (!self) { 01587 qWarning("QCoreApplication::arguments: Please instantiate the QApplication object first"); 01588 return list; 01589 } 01590 #ifdef Q_OS_WIN 01591 QString cmdline = QT_WA_INLINE(QString::fromUtf16((unsigned short *)GetCommandLineW()), QString::fromLocal8Bit(GetCommandLineA())); 01592 extern QStringList qWinCmdArgs(QString cmdLine); 01593 list = qWinCmdArgs(cmdline); 01594 if (self->d_func()->application_type) { // GUI app? Skip known - see qapplication.cpp 01595 QStringList stripped; 01596 for (int a = 0; a < list.count(); ++a) { 01597 QString arg = list.at(a); 01598 QByteArray l1arg = arg.toLatin1(); 01599 if (l1arg == "-qdevel" || 01600 l1arg == "-qdebug" || 01601 l1arg == "-reverse" || 01602 l1arg == "-widgetcount") 01603 ; 01604 else if (l1arg.startsWith("-style=")) 01605 ; 01606 else if (l1arg == "-style" || 01607 l1arg == "-session") 01608 ++a; 01609 else 01610 stripped += arg; 01611 } 01612 list = stripped; 01613 } 01614 #else 01615 const int ac = self->d_func()->argc; 01616 char ** const av = self->d_func()->argv; 01617 for (int a = 0; a < ac; ++a) { 01618 list << QString::fromLocal8Bit(av[a]); 01619 } 01620 #endif 01621 01622 return list; 01623 }
Here is the call graph for this function:

| void QCoreApplication::setAttribute | ( | Qt::ApplicationAttribute | attribute, | |
| bool | on = true | |||
| ) | [static] |
Sets the attribute attribute if on is true; otherwise clears the attribute.
Definition at line 501 of file qcoreapplication.cpp.
References QCoreApplicationPrivate::attribs.
00502 { 00503 if (on) 00504 QCoreApplicationPrivate::attribs |= 1 << attribute; 00505 else 00506 QCoreApplicationPrivate::attribs &= ~(1 << attribute); 00507 }
| bool QCoreApplication::testAttribute | ( | Qt::ApplicationAttribute | attribute | ) | [static] |
Returns true if attribute attribute is set; otherwise returns false.
Definition at line 515 of file qcoreapplication.cpp.
References QCoreApplicationPrivate::testAttribute().
00516 { 00517 return QCoreApplicationPrivate::testAttribute(attribute); 00518 }
Here is the call graph for this function:

| void QCoreApplication::setOrganizationDomain | ( | const QString & | orgDomain | ) | [static] |
| QString QCoreApplication::organizationDomain | ( | ) | [static] |
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.
Definition at line 1671 of file qcoreapplication.cpp.
Referenced by qDBusGenerateMetaObjectXml().
| void QCoreApplication::setOrganizationName | ( | const QString & | orgName | ) | [static] |
Definition at line 1641 of file qcoreapplication.cpp.
Referenced by main(), and QDesigner::QDesigner().
| QString QCoreApplication::organizationName | ( | ) | [static] |
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.
Definition at line 1646 of file qcoreapplication.cpp.
| void QCoreApplication::setApplicationName | ( | const QString & | application | ) | [static] |
Definition at line 1686 of file qcoreapplication.cpp.
Referenced by main(), and QDesigner::QDesigner().
| QString QCoreApplication::applicationName | ( | ) | [static] |
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.
Definition at line 1691 of file qcoreapplication.cpp.
Referenced by Main::updateStatus().
| static QCoreApplication * QCoreApplication::instance | ( | ) | [inline, static] |
Returns a pointer to the application's QCoreApplication (or QApplication) instance.
Definition at line 77 of file qcoreapplication.h.
Referenced by QDBusConnectionPrivate::bindToApplication(), QTranslatorPrivate::clear(), Translator::clear(), QWidgetPrivate::close_helper(), QInputContextFactory::description(), QInputContextFactory::displayName(), QEventDispatcherUNIXPrivate::doSelect(), QScrollArea::event(), QLibraryInfoPrivate::findConfiguration(), QTestEventLoop::instance(), QInputContextFactory::languages(), QLibraryInfo::location(), Pong::ping(), qAppName(), QDBusAbstractAdaptor::QDBusAbstractAdaptor(), qDBusAddTimeout(), qDBusAddWatch(), qDBusGenerateMetaObjectXml(), QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(), QEventLoop::QEventLoop(), QHostInfoAgent::QHostInfoAgent(), QSocks5BindStore::QSocks5BindStore(), qt_font_tread_test(), Pong::quit(), Main::quit(), QTest::qWait(), QX11EmbedContainer::QX11EmbedContainer(), QX11EmbedWidget::QX11EmbedWidget(), Porting::readXML(), QDBusConnectionPrivate::sendWithReply(), Oubliette::showVictory(), Ping::start(), QWindowsXPStylePrivate::useXP(), QX11EmbedWidget::x11Event(), QEvent::~QEvent(), and QTranslator::~QTranslator().
| int 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().
Definition at line 709 of file qcoreapplication.cpp.
References QCoreApplicationPrivate::checkInstance(), QThreadData::current(), QEvent::DeferredDelete, emit, QThreadData::eventLoops, QEventLoop::exec(), QVector< T >::isEmpty(), QThreadData::quitNow, qWarning(), self, and sendPostedEvents().
Referenced by QApplication::exec(), and main().
00710 { 00711 if (!QCoreApplicationPrivate::checkInstance("exec")) 00712 return -1; 00713 00714 QThreadData *threadData = self->d_func()->threadData; 00715 if (threadData != QThreadData::current()) { 00716 qWarning("%s::exec: Must be called from the main thread", self->metaObject()->className()); 00717 return -1; 00718 } 00719 if (!threadData->eventLoops.isEmpty()) { 00720 qWarning("QCoreApplication::exec: The event loop is already running"); 00721 return -1; 00722 } 00723 00724 threadData->quitNow = false; 00725 QEventLoop eventLoop; 00726 self->d_func()->in_exec = true; 00727 int returnCode = eventLoop.exec(); 00728 threadData->quitNow = false; 00729 if (self) { 00730 self->d_func()->in_exec = false; 00731 emit self->aboutToQuit(); 00732 sendPostedEvents(0, QEvent::DeferredDelete); 00733 } 00734 return returnCode; 00735 }
Here is the call graph for this function:

| void QCoreApplication::processEvents | ( | QEventLoop::ProcessEventsFlags | flags = QEventLoop::AllEvents |
) | [static] |
Processes all pending events 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).
Definition at line 657 of file qcoreapplication.cpp.
References QThreadData::current(), and data.
Referenced by qdesigner_internal::Layout::finishLayout(), MessageModel::load(), QTest::qWait(), and qdesigner_internal::AdjustWidgetSizeCommand::redo().
00658 { 00659 QThreadData *data = QThreadData::current(); 00660 if (!data->eventDispatcher) 00661 return; 00662 data->eventDispatcher->processEvents(flags); 00663 }
Here is the call graph for this function:

| void QCoreApplication::processEvents | ( | QEventLoop::ProcessEventsFlags | flags, | |
| int | maxtime | |||
| ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Processes pending events for maxtime milliseconds or until there are no more events to process, whichever is shorter.
You can call this function occasionally when you program is busy doing a long operation (e.g. copying a file).
Definition at line 676 of file qcoreapplication.cpp.
References QThreadData::current(), data, start, and QEventLoop::WaitForMoreEvents.
00677 { 00678 QThreadData *data = QThreadData::current(); 00679 if (!data->eventDispatcher) 00680 return; 00681 QTime start; 00682 start.start(); 00683 while (data->eventDispatcher->processEvents(flags & ~QEventLoop::WaitForMoreEvents)) { 00684 if (start.elapsed() > maxtime) 00685 break; 00686 } 00687 }
Here is the call graph for this function:

| void QCoreApplication::exit | ( | int | returnCode = 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.
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.
Definition at line 753 of file qcoreapplication.cpp.
Referenced by quit().
00754 { 00755 if (!self) 00756 return; 00757 QThreadData *data = self->d_func()->threadData; 00758 data->quitNow = true; 00759 for (int i = 0; i < data->eventLoops.size(); ++i) { 00760 QEventLoop *eventLoop = data->eventLoops.at(i); 00761 eventLoop->exit(returnCode); 00762 } 00763 }
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); QApplication::sendEvent(mainWindow, &event);
Definition at line 182 of file qcoreapplication.h.
References event().
Referenced by QEventDispatcherUNIX::activateSocketNotifiers(), QEventDispatcherUNIX::activateTimers(), Translator::clear(), QWidgetPrivate::close_helper(), Q3Table::contentsMousePressEventEx(), Q3Table::contentsMouseReleaseEvent(), QGraphicsView::contextMenuEvent(), QDialog::contextMenuEvent(), QApplicationPrivate::dispatchEnterLeave(), QShortcutMap::dispatchEvent(), QGraphicsView::dragEnterEvent(), QGraphicsView::dragLeaveEvent(), QGraphicsView::dragMoveEvent(), QGraphicsView::dropEvent(), QWidget::ensurePolished(), Q3TitleBar::enterEvent(), QWorkspaceTitleBar::enterEvent(), QApplicationPrivate::enterModal(), QWidget::event(), QApplication::event(), QMenuBar::event(), Q3FileDialog::eventFilter(), HoverPoints::eventFilter(), Q3DockArea::eventFilter(), QWhatsThisPrivate::eventFilter(), HelpDialog::eventFilter(), Q3ComboBox::eventFilter(), QFontDialog::eventFilter(), QGraphicsView::focusInEvent(), QGraphicsView::focusOutEvent(), grabWidget_helper(), handle_xdnd_position(), QDesignerMenu::handleKeyPressEvent(), QDesignerMenuBar::handleKeyPressEvent(), QDesignerMenu::handleMouseDoubleClickEvent(), CursorWindow::handleMouseEvent(), QDesignerMenu::handleMouseMoveEvent(), QDesignerMenu::handleMousePressEvent(), Q3DockWindow::handleMove(), QWidgetPrivate::hide_helper(), QWidgetPrivate::hideChildren(), QWidgetPrivate::init(), QGraphicsView::inputMethodEvent(), QWidget::insertAction(), installTranslator(), Q3Table::keyPressEvent(), QGraphicsView::keyPressEvent(), Q3ListBox::keyPressEvent(), QMenu::keyPressEvent(), QGraphicsView::keyReleaseEvent(), QApplicationPrivate::leaveModal(), QWidget::lower(), QX11Data::motifdndHandle(), QGraphicsView::mouseDoubleClickEvent(), QAbstractItemView::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), QGraphicsScene::mouseReleaseEvent(), QWhatsThat::mouseReleaseEvent(), QObjectPrivate::moveToThread_helper(), QApplication::notify(), QWhatsThisPrivate::notifyToplevels(), QAbstractItemViewPrivate::openEditor(), QWidget::overrideWindowState(), QWidgetPrivate::propagatePaletteChange(), QAccessible::queryAccessibleInterface(), QWhatsThisPrivate::QWhatsThisPrivate(), QWidget::raise(), QWidget::removeAction(), removeTranslator(), QWidgetPrivate::scrollChildren(), QDBusConnectionPrivate::sendCallDeliveryEvent(), QActionPrivate::sendDataChanged(), sendPostedEvents(), sendResizeEvents(), QWidget::setAttribute(), QWidget::setContentsMargins(), QMenuBarPrivate::setCurrentAction(), QMenuPrivate::setCurrentAction(), QWidgetPrivate::setEnabled_helper(), QGraphicsScene::setFocus(), QApplicationPrivate::setFocusWidget(), QApplication::setFont(), QWidgetPrivate::setFont_helper(), QWidgetPrivate::setGeometry_sys(), QApplication::setLayoutDirection(), QWidgetPrivate::setLayoutDirection_helper(), QApplicationPrivate::setPalette_helper(), QWidget::setParent(), QObjectPrivate::setParent_helper(), QObject::setProperty(), QApplication::setStyle(), QWidgetPrivate::setStyle_helper(), QDialog::setVisible(), QWidget::setVisible(), QApplication::setWindowIcon(), QWidget::setWindowIcon(), QWidget::setWindowIconText(), QWidget::setWindowModified(), QWidget::setWindowState(), QWidget::setWindowTitle(), QWidgetPrivate::show_helper(), QAction::showStatusText(), QDesignerActions::shutdown(), sm_dieCallback(), socketNotifierSourceDispatch(), QWidget::stackUnder(), Q3AccessibleHeader::text(), QAccessibleHeader::text(), timerSourceDispatch(), QETWidget::translateConfigEvent(), Q3AccelManager::tryComposeUnicode(), QMenuBarPrivate::updateGeometries(), updateWidget(), QGraphicsView::viewportEvent(), Q3ComboBox::wheelEvent(), QAbstractScrollArea::wheelEvent(), QGraphicsView::wheelEvent(), x11EventFilter(), QX11Data::xdndHandleBadwindow(), QX11Data::xdndHandleDrop(), QX11Data::xdndHandleLeave(), QApplication::~QApplication(), and QWidget::~QWidget().
00183 { if (event) event->spont = false; return self ? self->notify(receiver, event) : false; }
Here is the call graph for this function:

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 modify or delete 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.
Definition at line 803 of file qcoreapplication.cpp.
References data, QEvent::DeferredDelete, event(), i, QObjectPrivate::isValidObject(), qWarning(), and QObjectPrivate::readWriteLock().
Referenced by QToolBar::actionEvent(), QTranslatorPrivate::clear(), QObject::deleteLater(), QWidgetPrivate::dirtyWidget_sys(), QApplication::event(), Q3ListView::eventFilter(), QWidgetPrivate::init(), QMetaObject::invokeMethod(), Q3DockWindowTitleBar::mouseDoubleClickEvent(), Q3DockWindowHandle::mouseDoubleClickEvent(), Q3DockWindowResizeHandle::mouseReleaseEvent(), Q3DockWindowTitleBar::mouseReleaseEvent(), Q3DockWindowHandle::mouseReleaseEvent(), QDBusConnectionPrivate::postCallDeliveryEvent(), queued_activate(), QGraphicsViewPrivate::replayLastMouseEvent(), QSettingsPrivate::requestUpdate(), QMainWindow::restoreState(), QDirModel::setData(), Q3Wizard::setFont(), Q3DockWindow::setOrientation(), QWidget::setParent(), QObjectPrivate::setParent_helper(), QWidgetPrivate::setParent_sys(), QWidget::setVisible(), Q3MainWindow::triggerLayout(), QLayout::update(), QWidget::update(), and QWidget::updateGeometry().
00804 { 00805 if (receiver == 0) { 00806 qWarning("QCoreApplication::postEvent: Unexpected null receiver"); 00807 delete event; 00808 return; 00809 } 00810 00811 QReadLocker locker(QObjectPrivate::readWriteLock()); 00812 if (!QObjectPrivate::isValidObject(receiver)) { 00813 qWarning("QCoreApplication::postEvent: Receiver is not a valid QObject"); 00814 delete event; 00815 return; 00816 } 00817 00818 QThreadData *data = receiver->d_func()->threadData; 00819 if (!data) { 00820 // posting during destruction? just delete the event to prevent a leak 00821 delete event; 00822 return; 00823 } 00824 00825 { 00826 QMutexLocker locker(&data->postEventList.mutex); 00827 00828 // if this is one of the compressible events, do compression 00829 if (receiver->d_func()->postedEvents 00830 && self && self->compressEvent(event, receiver, &data->postEventList)) { 00831 delete event; 00832 return; 00833 } 00834 00835 event->posted = true; 00836 ++receiver->d_func()->postedEvents; 00837 #ifdef QT3_SUPPORT 00838 if (event->type() == QEvent::ChildInserted) 00839 ++receiver->d_func()->postedChildInsertedEvents; 00840 #endif 00841 if (event->type() == QEvent::DeferredDelete) { 00842 if (!data->eventLoops.isEmpty()) { 00843 // remember the current running eventloop 00844 for (int i = data->eventLoops.size() - 1; i >= 0; --i) { 00845 QEventLoop *eventLoop = data->eventLoops.at(i); 00846 if (eventLoop->isRunning()) { 00847 event->d = reinterpret_cast<QEventPrivate *>(eventLoop); 00848 break; 00849 } 00850 } 00851 } 00852 } 00853 data->postEventList.append(QPostEvent(receiver, event)); 00854 data->canWait = false; 00855 } 00856 00857 if (data->eventDispatcher) 00858 data->eventDispatcher->wakeUp(); 00859 }
Here is the call graph for this function:

| void 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.
Note that 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.
Definition at line 912 of file qcoreapplication.cpp.
References QThreadData::current(), QEvent::d, data, QEvent::DeferredDelete, event(), QPostEvent::event, i, QList< QPostEvent >::iterator, QEvent::posted, qWarning(), QPostEvent::receiver, QMutexLocker::relock(), s, sendEvent(), sendPostedEvents(), QEvent::type(), and QMutexLocker::unlock().
00913 { 00914 bool doDeferredDeletion = (event_type == QEvent::DeferredDelete); 00915 if (event_type == -1) { 00916 // we were called by the event dispatcher. 00917 doDeferredDeletion = true; 00918 event_type = 0; 00919 } 00920 00921 QThreadData *data = QThreadData::current(); 00922 00923 if (receiver && receiver->d_func()->threadData != data) { 00924 qWarning("QCoreApplication::sendPostedEvents: Cannot send " 00925 "posted events for objects in another thread"); 00926 return; 00927 } 00928 00929 ++data->postEventList.recursion; 00930 00931 #ifdef QT3_SUPPORT 00932 // optimize sendPostedEvents(w, QEvent::ChildInserted) calls away 00933 if (receiver && event_type == QEvent::ChildInserted 00934 && !receiver->d_func()->postedChildInsertedEvents) { 00935 --data->postEventList.recursion; 00936 return; 00937 } 00938 // Make sure the object hierarchy is stable before processing events 00939 // to avoid endless loops 00940 if (receiver == 0 && event_type == 0) 00941 sendPostedEvents(0, QEvent::ChildInserted); 00942 #endif 00943 00944 QMutexLocker locker(&data->postEventList.mutex); 00945 00946 // by default, we assume that the event dispatcher can go to sleep after 00947 // processing all events. if any new events are posted while we send 00948 // events, canWait will be set to false. 00949 data->canWait = (data->postEventList.size() == 0); 00950 00951 if (data->postEventList.size() == 0 || (receiver && !receiver->d_func()->postedEvents)) { 00952 --data->postEventList.recursion; 00953 return; 00954 } 00955 00956 data->canWait = true; 00957 00958 // okay. here is the tricky loop. be careful about optimizing 00959 // this, it looks the way it does for good reasons. 00960 int i = 0; 00961 const int s = data->postEventList.size(); 00962 while (i < data->postEventList.size()) { 00963 // avoid live-lock 00964 if (i >= s) 00965 break; 00966 00967 const QPostEvent &pe = data->postEventList.at(i); 00968 ++i; 00969 00970 if (!pe.event) 00971 continue; 00972 if ((receiver && receiver != pe.receiver) || (event_type && event_type != pe.event->type())) { 00973 data->canWait = false; 00974 continue; 00975 } 00976 00977 if (pe.event->type() == QEvent::DeferredDelete) { 00978 const QEventLoop *const savedEventLoop = reinterpret_cast<QEventLoop *>(pe.event->d); 00979 const QEventLoop *const currentEventLoop = 00980 data->eventLoops.isEmpty() ? 0 : data->eventLoops.top(); 00981 00982 // DeferredDelete events are only sent when we are explicitly 00983 // asked to (s.a. QEventLoop::DeferredDeletion), and then only if 00984 // there is no current event loop, or if the current event loop is 00985 // equal to the loop in which deleteLater() was called. 00986 if (!doDeferredDeletion || (currentEventLoop && savedEventLoop && savedEventLoop != currentEventLoop)) { 00987 // cannot send deferred delete 00988 if (!event_type && !receiver) { 00989 // don't lose the event 00990 data->postEventList.append(pe); 00991 const_cast<QPostEvent &>(pe).event = 0; 00992 } 00993 continue; 00994 } 00995 } 00996 00997 // first, we diddle the event so that we can deliver 00998 // it, and that no one will try to touch it later. 00999 pe.event->posted = false; 01000 QEvent * e = pe.event; 01001 QObject * r = pe.receiver; 01002 01003 --r->d_func()->postedEvents; 01004 Q_ASSERT(r->d_func()->postedEvents >= 0); 01005 #ifdef QT3_SUPPORT 01006 if (e->type() == QEvent::ChildInserted) 01007 --r->d_func()->postedChildInsertedEvents; 01008 Q_ASSERT(r->d_func()->postedChildInsertedEvents >= 0); 01009 #endif 01010 01011 // next, update the data structure so that we're ready 01012 // for the next event. 01013 const_cast<QPostEvent &>(pe).event = 0; 01014 01015 locker.unlock(); 01016 // after all that work, it's time to deliver the event. 01017 #ifdef QT_NO_EXCEPTIONS 01018 QCoreApplication::sendEvent(r, e); 01019 #else 01020 try { 01021 QCoreApplication::sendEvent(r, e); 01022 } catch (...) { 01023 locker.relock(); 01024 delete e; 01025 01026 // since we were interrupted, we need another pass to make sure we clean everything up 01027 data->canWait = false; 01028 01029 // uglehack: copied from below 01030 --data->postEventList.recursion; 01031 if (!data->postEventList.recursion && !data->canWait && data->eventDispatcher) 01032 data->eventDispatcher->wakeUp(); 01033 throw; // rethrow 01034 } 01035 #endif 01036 01037 locker.relock(); 01038 01039 delete e; 01040 // careful when adding anything below this point - the 01041 // sendEvent() call might invalidate any invariants this 01042 // function depends on. 01043 } 01044 01045 --data->postEventList.recursion; 01046 if (!data->postEventList.recursion && !data->canWait && data->eventDispatcher) 01047 data->eventDispatcher->wakeUp(); 01048 01049 // clear the global list, i.e. remove everything that was 01050 // delivered. 01051 if (!data->postEventList.recursion && !event_type && !receiver) { 01052 const QPostEventList::iterator it = data->postEventList.begin(); 01053 data->postEventList.erase(it, it + i); 01054 } 01055 }
Here is the call graph for this function:

| void QCoreApplication::sendPostedEvents | ( | ) | [inline, static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Dispatches all posted events, i.e. empties the event queue.
Definition at line 188 of file qcoreapplication.h.
Referenced by Q3GroupBox::addSpace(), QAbstractItemView::closeEditor(), Q3Table::contentsMousePressEventEx(), Q3Table::contentsMouseReleaseEvent(), QMainWindow::event(), QWidget::event(), Q3MainWindow::event(), exec(), postEventSourceDispatch(), QEventDispatcherUNIX::processEvents(), QEventDispatcherX11::processEvents(), Q3WidgetStack::raiseWidget(), Q3IconView::selectAll(), sendPostedEvents(), Q3GroupBox::setColumnLayout(), Q3DockWindow::setOrientation(), Q3HBox::setStretchFactor(), QWidget::setVisible(), QWidgetPrivate::show_helper(), QWidgetPrivate::show_recursive(), QWidget::showFullScreen(), QWidget::showMaximized(), QWidget::showMinimized(), QWidget::showNormal(), Q3MainWindow::sizeHint(), Q3Grid::sizeHint(), Q3HBox::sizeHint(), Q3DockWindow::undock(), and Q3DockWindow::updatePosition().
00188 { sendPostedEvents(0, 0); }
| void 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.
Definition at line 1070 of file qcoreapplication.cpp.
References data, QObject::event(), event(), i, j, and n.
Referenced by QObject::~QObject(), and QWidget::~QWidget().
01071 { 01072 #ifdef PAUL_TESTING 01073 QThreadData *data = receiver ? receiver->d_func()->threadData : self->d_func()->threadData; 01074 #else 01075 if (!receiver) 01076 return; 01077 01078 QThreadData *data = receiver->d_func()->threadData; 01079 #endif 01080 01081 QMutexLocker locker(&data->postEventList.mutex); 01082 01083 // the QObject destructor calls this function directly. this can 01084 // happen while the event loop is in the middle of posting events, 01085 // and when we get here, we may not have any more posted events 01086 // for this object. 01087 #ifdef PAUL_TESTING 01088 if (receiver && !receiver->d_func()->postedEvents) return; 01089 #else 01090 if (!receiver->d_func()->postedEvents) return; 01091 #endif 01092 int n = data->postEventList.size(); 01093 int j = 0; 01094 01095 #ifdef PAUL_TESTING 01096 if (!receiver) { 01097 for (int i = 0; i < n; ++i) { 01098 const QPostEvent &pe = data->postEventList.at(i); 01099 if (pe.event) { 01100 --pe.receiver->d_func()->postedEvents; 01101 #ifdef QT3_SUPPORT 01102 if (pe.event->type() == QEvent::ChildInserted) 01103 --pe.receiver->d_func()->postedChildInsertedEvents; 01104 #endif 01105 pe.event->posted = false; 01106 delete pe.event; 01107 const_cast<QPostEvent &>(pe).event = 0; 01108 01109 } 01110 } 01111 data->postEventList.clear(); 01112 return; 01113 } 01114 #endif 01115 01116 for (int i = 0; i < n; ++i) { 01117 const QPostEvent &pe = data->postEventList.at(i); 01118 if (pe.receiver == receiver) { 01119 if (pe.event) { 01120 --receiver->d_func()->postedEvents; 01121 #ifdef QT3_SUPPORT 01122 if (pe.event->type() == QEvent::ChildInserted) 01123 --receiver->d_func()->postedChildInsertedEvents; 01124 #endif 01125 pe.event->posted = false; 01126 delete pe.event; 01127 const_cast<QPostEvent &>(pe).event = 0; 01128 } 01129 } else if (!data->postEventList.recursion) { 01130 if (i != j) 01131 data->postEventList.swap(i, j); 01132 ++j; 01133 } 01134 } 01135 01136 Q_ASSERT(!receiver->d_func()->postedEvents); 01137 #ifdef QT3_SUPPORT 01138 Q_ASSERT(!receiver->d_func()->postedChildInsertedEvents); 01139 #endif 01140 if (!data->postEventList.recursion) { 01141 while (j++ < n) 01142 data->postEventList.removeLast(); 01143 } 01144 }
Here is the call graph for this function:

| bool 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().
Definition at line 1884 of file qcoreapplication.cpp.
References QAbstractEventDispatcher::hasPendingEvents(), and QAbstractEventDispatcher::instance().
01885 { 01886 QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); 01887 if (eventDispatcher) 01888 return eventDispatcher->hasPendingEvents(); 01889 return false; 01890 }
Here is the call graph for this function:

Sends event to receiver: {receiver}->event(event). Returns the value that is returned from the receiver's event handler.
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.
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 {QWidget::isEnabled()}{disabled widgets}.
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 except Tab and Shift-Tab key presses.
Definition at line 559 of file qcoreapplication.cpp.
References QEvent::ChildRemoved, d, event(), QCoreApplicationPrivate::is_app_closing, QObject::isWidgetType(), and qWarning().
00560 { 00561 Q_D(QCoreApplication); 00562 // no events are delivered after ~QCoreApplication() has started 00563 if (QCoreApplicationPrivate::is_app_closing) 00564 return true; 00565 00566 if (receiver == 0) { // serious error 00567 qWarning("QCoreApplication::notify: Unexpected null receiver"); 00568 return true; 00569 } 00570 00571 d->checkReceiverThread(receiver); 00572 00573 #ifdef QT3_SUPPORT 00574 if (event->type() == QEvent::ChildRemoved && receiver->d_func()->postedChildInsertedEvents) 00575 d->removePostedChildInsertedEvents(receiver, static_cast<QChildEvent *>(event)->child()); 00576 #endif // QT3_SUPPORT 00577 00578 return receiver->isWidgetType() ? false : d->notify_helper(receiver, event); 00579 }
Here is the call graph for this function:

| bool QCoreApplication::startingUp | ( | ) | [static] |
Returns true if an application object has not been created yet; otherwise returns false.
Definition at line 630 of file qcoreapplication.cpp.
References QCoreApplicationPrivate::is_app_running.
00631 { 00632 return !QCoreApplicationPrivate::is_app_running; 00633 }
| bool QCoreApplication::closingDown | ( | ) | [static] |
Returns true if the application objects are being destroyed; otherwise returns false.
Definition at line 642 of file qcoreapplication.cpp.
References QCoreApplicationPrivate::is_app_closing.
Referenced by QSizeGrip::event(), and QApplication::restoreOverrideCursor().
00643 { 00644 return QCoreApplicationPrivate::is_app_closing; 00645 }
| QString QCoreApplication::applicationDirPath | ( | ) | [static] |
Returns the directory that contains the application executable.
For example, if you have installed Qt in the {C:} 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).
Definition at line 1438 of file qcoreapplication.cpp.
References applicationFilePath(), and qWarning().
Referenced by QLibraryInfoPrivate::findConfiguration(), QLibraryInfo::location(), and main().
01439 { 01440 if (!self) { 01441 qWarning("QCoreApplication::applicationDirPath: Please instantiate the QApplication object first"); 01442 return QString(); 01443 } 01444 return QFileInfo(applicationFilePath()).path(); 01445 }
Here is the call graph for this function:

| QString 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".
Definition at line 1460 of file qcoreapplication.cpp.
References QDir::absoluteFilePath(), QString::at(), QFileInfo::canonicalFilePath(), QDir::cleanPath(), QList< QString >::const_iterator, QList< T >::constBegin(), QByteArray::constData(), QList< T >::constEnd(), QString::contains(), QDir::current(), QFile::decodeName(), QFile::exists(), QFileInfo::exists(), QFileInfo::filePath(), QString::fromLatin1(), QString::fromLocal8Bit(), QString::fromUtf16(), QString::isEmpty(), QFileInfo::isSymLink(), p, qgetenv(), and qWarning().
Referenced by QCoreApplicationPrivate::appendApplicationPathToLibraryPaths(), and applicationDirPath().
01461 { 01462 if (!self) { 01463 qWarning("QCoreApplication::applicationFilePath: Please instantiate the QApplication object first"); 01464 return QString(); 01465 } 01466 #if defined( Q_WS_WIN ) 01467 QFileInfo filePath; 01468 QT_WA({ 01469 wchar_t module_name[256]; 01470 GetModuleFileNameW(0, module_name, sizeof(module_name) / sizeof(wchar_t)); 01471 filePath = QString::fromUtf16((ushort *)module_name); 01472 }, { 01473 char module_name[256]; 01474 GetModuleFileNameA(0, module_name, sizeof(module_name)); 01475 filePath = QString::fromLocal8Bit(module_name); 01476 }); 01477 01478 return filePath.filePath(); 01479 #elif defined(Q_WS_MAC) 01480 QFileInfo fi(qAppFileName()); 01481 return fi.exists() ? fi.canonicalFilePath() : QString(); 01482 #else 01483 # ifdef Q_OS_LINUX 01484 // Try looking for a /proc/<pid>/exe symlink first which points to 01485 // the absolute path of the executable 01486 QFileInfo pfi(QString::fromLatin1("/proc/%1/exe").arg(getpid())); 01487 if (pfi.exists() && pfi.isSymLink()) 01488 return pfi.canonicalFilePath(); 01489 # endif 01490 01491 QString argv0 = QFile::decodeName(QByteArray(argv()[0])); 01492 QString absPath; 01493 01494 if (!argv0.isEmpty() && argv0.at(0) == QLatin1Char('/')) { 01495 /* 01496 If argv0 starts with a slash, it is already an absolute 01497 file path. 01498 */ 01499 absPath = argv0; 01500 } else if (argv0.contains(QLatin1Char('/'))) { 01501 /* 01502 If argv0 contains one or more slashes, it is a file path 01503 relative to the current directory. 01504 */ 01505 absPath = QDir::current().absoluteFilePath(argv0); 01506 } else { 01507 /* 01508 Otherwise, the file path has to be determined using the 01509 PATH environment variable. 01510 */ 01511 QByteArray pEnv = qgetenv("PATH"); 01512 QDir currentDir = QDir::current(); 01513 QStringList paths = QString::fromLocal8Bit(pEnv.constData()).split(QLatin1String(":")); 01514 for (QStringList::const_iterator p = paths.constBegin(); p != paths.constEnd(); ++p) { 01515 if ((*p).isEmpty()) 01516 continue; 01517 QString candidate = currentDir.absoluteFilePath(*p + QLatin1Char('/') + argv0); 01518 if (QFile::exists(candidate)) { 01519 absPath = candidate; 01520 break; 01521 } 01522 } 01523 } 01524 01525 absPath = QDir::cleanPath(absPath); 01526 01527 QFileInfo fi(absPath); 01528 return fi.exists() ? fi.canonicalFilePath() : QString(); 01529 #endif 01530 }
Here is the call graph for this function:

| 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.
Definition at line 1767 of file qcoreapplication.cpp.
| static QStringList QCoreApplication::libraryPaths | ( | ) | [static] |
Referenced by addLibraryPath(), QDesignerPluginManager::defaultPluginPaths(), init(), QUiLoader::QUiLoader(), and removeLibraryPath().
| void QCoreApplication::addLibraryPath | ( | const QString & | path | ) | [static] |
Appends path to the end of the library path list. 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.
Definition at line 1782 of file qcoreapplication.cpp.
References libraryPaths(), and path.
01783 { 01784 if (path.isEmpty()) 01785 return; 01786 01787 // make sure that library paths is initialized 01788 libraryPaths(); 01789 01790 QString canonicalPath = QDir(path).canonicalPath(); 01791 if (!coreappdata()->app_libpaths->contains(canonicalPath)) 01792 coreappdata()->app_libpaths->prepend(canonicalPath); 01793 }
Here is the call graph for this function:

| 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.
Definition at line 1801 of file qcoreapplication.cpp.
References libraryPaths(), and path.
01802 { 01803 if (path.isEmpty()) 01804 return; 01805 01806 // make sure that library paths is initialized 01807 libraryPaths(); 01808 01809 coreappdata()->app_libpaths->removeAll(path); 01810 }
Here is the call graph for this function:

| void QCoreApplication::installTranslator | ( | QTranslator * | translationFile | ) | [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 last installed translation file on, back to the first installed translation file. The search stops as soon as a matching translation is found.
Definition at line 1273 of file qcoreapplication.cpp.
References QCoreApplicationPrivate::checkInstance(), d, QTranslator::isEmpty(), QEvent::LanguageChange, and sendEvent().
Referenced by TrPreviewTool::event(), QDesigner::initialize(), main(), and TrPreviewTool::translationSelected().
01274 { 01275 if (!translationFile) 01276 return; 01277 01278 if (!QCoreApplicationPrivate::checkInstance("installTranslator")) 01279 return; 01280 QCoreApplicationPrivate *d = self->d_func(); 01281 d->translators.prepend(translationFile); 01282 01283 #ifndef QT_NO_TRANSLATION_BUILDER 01284 if (translationFile->isEmpty()) 01285 return; 01286 #endif 01287 01288 QEvent ev(QEvent::LanguageChange); 01289 QCoreApplication::sendEvent(self, &ev); 01290 }
Here is the call graph for this function:

| 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.)
Definition at line 1300 of file qcoreapplication.cpp.
References QCoreApplicationPrivate::checkInstance(), d, QEvent::LanguageChange, and sendEvent().
Referenced by TrPreviewTool::event(), TrPreviewTool::translationSelected(), and QTranslator::~QTranslator().
01301 { 01302 if (!translationFile) 01303 return; 01304 if (!QCoreApplicationPrivate::checkInstance("removeTranslator")) 01305 return; 01306 QCoreApplicationPrivate *d = self->d_func(); 01307 if (d->translators.removeAll(translationFile) && !self->closingDown()) { 01308 QEvent ev(QEvent::LanguageChange); 01309 QCoreApplication::sendEvent(self, &ev); 01310 } 01311 }
Here is the call graph for this function:

| QString QCoreApplication::translate | ( | const char * | context, | |
| const char * | sourceText, | |||
| const char * | comment = 0, |
|||
| Encoding | encoding = CodecForTr | |||
| ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 1316 of file qcoreapplication.cpp.
Referenced by QPrintDialogPrivate::_q_btnBrowseClicked(), QPrintDialogPrivate::_q_printToFileChanged(), TrWindow::about(), qdesigner_internal::AddConnectionCommand::AddConnectionCommand(), qdesigner_internal::AdjustConnectionCommand::AdjustConnectionCommand(), FormBuilderPrivate::applyProperties(), qdesigner_internal::QDesignerResource::create(), FormBuilderPrivate::create(), qdesigner_internal::QDesignerResource::createCustomWidgets(), qdesigner_internal::QDesignerResource::createResources(), qdesigner_internal::DeleteConnectionsCommand::DeleteConnectionsCommand(), QODBCResult::exec(), QSQLiteResult::exec(), QMYSQLResult::fetch(), QODBCResult::fetchNext(), QSQLiteResultPrivate::fetchNext(), QSQLite2ResultPrivate::finalize(), PPDOptionsModel::headerData(), QDirModel::index(), qdesigner_internal::SetPropertyCommand::init(), qdesigner_internal::LowerWidgetCommand::init(), qdesigner_internal::DeleteWidgetCommand::init(), qdesigner_internal::MoveStackedWidgetCommand::init(), qdesigner_internal::DeleteContainerWidgetPageCommand::init(), qdesigner_internal::LayoutCommand::init(), qdesigner_internal::AddStackedWidgetPageCommand::init(), QPrintDialogPrivate::init(), qdesigner_internal::SetFormPropertyCommand::init(), qdesigner_internal::DeleteToolBoxPageCommand::init(), qdesigner_internal::AddToolBoxPageCommand::init(), qdesigner_internal::ResetPropertyCommand::init(), qdesigner_internal::AdjustWidgetSizeCommand::init(), qdesigner_internal::ReparentWidgetCommand::init(), qdesigner_internal::DeleteTabPageCommand::init(), qdesigner_internal::AddContainerWidgetPageCommand::init(), qdesigner_internal::InsertWidgetCommand::init(), qdesigner_internal::RaiseWidgetCommand::init(), qdesigner_internal::MoveToolBoxPageCommand::init(), qdesigner_internal::DeleteStackedWidgetPageCommand::init(), qdesigner_internal::AddTabPageCommand::init(), qdesigner_internal::MoveTabPageCommand::init(), QIBaseResultPrivate::isError(), QIBaseDriverPrivate::isError(), qdesigner_internal::ResourceFile::load(), qdesigner_internal::ModelCache::model(), NewForm::NewForm(), QODBCResult::prepare(), QSQLiteResult::prepare(), QPSQLResultPrivate::processResults(), QPageSetupDialog::QPageSetupDialog(), recursiveTranslate(), QODBCResult::reset(), QMYSQLResult::reset(), QSQLite2Result::reset(), qdesigner_internal::QDesignerResource::save(), qdesigner_internal::ResourceFile::save(), qdesigner_internal::SetEndPointCommand::SetEndPointCommand(), qdesigner_internal::SetMemberCommand::SetMemberCommand(), qdesigner_internal::SignalSlotEditor::setSignal(), qdesigner_internal::SignalSlotEditor::setSlot(), qdesigner_internal::SignalSlotEditor::setSource(), qdesigner_internal::SignalSlotEditor::setTarget(), qdesigner_internal::QtBrushEditorPrivate::slotAddToCustomClicked(), qdesigner_internal::QtBrushPatternEditorPrivate::slotHsvClicked(), qdesigner_internal::QtGradientStopsEditorPrivate::slotHsvClicked(), qdesigner_internal::QtBrushPatternEditorPrivate::slotRgbClicked(), qdesigner_internal::QtGradientStopsEditorPrivate::slotRgbClicked(), QMetaObject::tr(), QMetaObject::trUtf8(), and QFileIconProvider::type().
01318 { 01319 return translate(context, sourceText, comment, encoding, -1); 01320 }
| QString QCoreApplication::translate | ( | const char * | context, | |
| const char * | sourceText, | |||
| const char * | comment, | |||
| 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.
comment is a disambiguating comment, for when the same sourceText is used in different roles within the same context. By default, it is null. encoding indicates the 8-bit encoding of character stings See the QTranslator documentation for more information about contexts and comments.
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.
Definition at line 1363 of file qcoreapplication.cpp.
References QString::arg(), QTextCodec::codecForTr(), QString::fromLatin1(), QString::fromUtf8(), QString::indexOf(), QString::isEmpty(), len, QString::mid(), QString::replace(), self, QString::startsWith(), QTextCodec::toUnicode(), QTranslator::translate(), and UnicodeUTF8.
01365 { 01366 QString result; 01367 01368 if (!sourceText) 01369 return result; 01370 01371 if (self && !self->d_func()->translators.isEmpty()) { 01372 QList<QTranslator*>::ConstIterator it; 01373 QTranslator *translationFile; 01374 for (it = self->d_func()->translators.constBegin(); it != self->d_func()->translators.constEnd(); ++it) { 01375 translationFile = *it; 01376 result = translationFile->translate(context, sourceText, comment, n); 01377 if (!result.isEmpty()) 01378 break; 01379 } 01380 } 01381 01382 if (result.isEmpty()) { 01383 #ifdef QT_NO_TEXTCODEC 01384 Q_UNUSED(encoding) 01385 #else 01386 if (encoding == UnicodeUTF8) 01387 result = QString::fromUtf8(sourceText); 01388 else if (QTextCodec::codecForTr() != 0) 01389 result = QTextCodec::codecForTr()->toUnicode(sourceText); 01390 else 01391 #endif 01392 result = QString::fromLatin1(sourceText); 01393 } 01394 01395 if (n >= 0) { 01396 int percentPos = -1; 01397 while ((percentPos = result.indexOf(QLatin1Char('%'), percentPos + 1)) != -1) { 01398 int len = 1; 01399 QString fmt(QLatin1String("%1")); 01400 if (result.mid(percentPos + len, 1).startsWith(QLatin1Char('L'))) { 01401 ++len; 01402 fmt = QLatin1String("%L1"); 01403 } 01404 if (result.mid(percentPos + len, 1).startsWith(QLatin1Char('n'))) { 01405 ++len; 01406 result.replace(percentPos, len, fmt.arg(n)); 01407 } 01408 } 01409 } 01410 return result; 01411 }
Here is the call graph for this function:

| 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 function.
Definition at line 391 of file qcoreapplication.cpp.
Referenced by QAbstractButton::animateClick(), QAbstractButtonPrivate::click(), QDragManager::drag(), QWindowsStyle::drawComplexControl(), flush(), QAbstractButton::keyPressEvent(), QAbstractButton::mouseMoveEvent(), QAbstractButton::mousePressEvent(), qt_x11_wait_for_window_manager(), QSplashScreen::repaint(), Q3ProgressDialog::setProgress(), and QProgressDialog::setValue().
00392 { 00393 if (self && self->d_func()->eventDispatcher) 00394 self->d_func()->eventDispatcher->flush(); 00395 }
Here is the call graph for this function:

| QCoreApplication::EventFilter QCoreApplication::setEventFilter | ( | QCoreApplication::EventFilter | filter | ) |
Sets the event filter filter. Returns a pointer to the filter function previously defined.
The event filter is a function that is called for every message received in all threads. This does not include messages to objects that are not handled by Qt.
The function can return true to stop the event to be processed by Qt, or false to continue with the standard event processing.
Only one filter can be defined, but the filter can use the return value to call the previously set event filter. By default, no filter is set (i.e., the function returns 0).
Definition at line 1847 of file qcoreapplication.cpp.
References d.
Referenced by QX11EmbedContainer::QX11EmbedContainer().
01848 { 01849 Q_D(QCoreApplication); 01850 EventFilter old = d->eventFilter; 01851 d->eventFilter = filter; 01852 return old; 01853 }
| bool QCoreApplication::filterEvent | ( | void * | message, | |
| long * | result | |||
| ) |
Sends message through the event filter that was set by setEventFilter(). If no event filter has been set, this function returns false; otherwise, this function returns the result of the event filter function in the result parameter.
Definition at line 1863 of file qcoreapplication.cpp.
References d.
01864 { 01865 Q_D(QCoreApplication); 01866 if (result) 01867 *result = 0; 01868 if (d->eventFilter) 01869 return d->eventFilter(message, result); 01870 #ifdef Q_OS_WIN 01871 return winEventFilter(reinterpret_cast<MSG *>(message), result); 01872 #else 01873 return false; 01874 #endif 01875 }
| void QCoreApplication::quit | ( | ) | [static, slot] |
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()));
Definition at line 1240 of file qcoreapplication.cpp.
References exit().
Referenced by event(), Main::quit(), Oubliette::showVictory(), and Ping::start().
01241 { 01242 exit(0); 01243 }
| 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. Note that no user interaction is possible in this state.
| void QCoreApplication::unixSignal | ( | int | ) | [signal] |
Referenced by QEventDispatcherUNIXPrivate::doSelect().
| bool QCoreApplication::event | ( | QEvent * | e | ) | [protected, virtual] |
Reimplemented from QObject.
Definition at line 1199 of file qcoreapplication.cpp.
References QObject::event(), quit(), QEvent::Quit, and QEvent::type().
Referenced by compressEvent(), QApplication::event(), notify(), postEvent(), removePostedEvents(), sendEvent(), sendPostedEvents(), and sendSpontaneousEvent().
01200 { 01201 if (e->type() == QEvent::Quit) { 01202 quit(); 01203 return true; 01204 } 01205 return QObject::event(e); 01206 }
Here is the call graph for this function:

| bool QCoreApplication::compressEvent | ( | QEvent * | , | |
| QObject * | receiver, | |||
| QPostEventList * | ||||
| ) | [protected, virtual] |
Definition at line 865 of file qcoreapplication.cpp.
References QList< T >::at(), QObject::event(), event(), i, QList< T >::size(), QEvent::Timer, and timerId.
Referenced by QApplication::compressEvent().
00866 { 00867 #ifdef Q_WS_WIN 00868 Q_ASSERT(event); 00869 Q_ASSERT(receiver); 00870 Q_ASSERT(postedEvents); 00871 00872 // compress posted timers to this object. 00873 if (event->type() == QEvent::Timer && receiver->d_func()->postedEvents > 0) { 00874 int timerId = ((QTimerEvent *) event)->timerId(); 00875 for (int i=0; i<postedEvents->size(); ++i) { 00876 const QPostEvent &e = postedEvents->at(i); 00877 if (e.receiver == receiver && e.event && e.event->type() == QEvent::Timer 00878 && ((QTimerEvent *) e.event)->timerId() == timerId) 00879 return true; 00880 } 00881 } 00882 #else 00883 Q_UNUSED(event); 00884 Q_UNUSED(receiver); 00885 Q_UNUSED(postedEvents); 00886 #endif 00887 00888 return false; 00889 }
Here is the call graph for this function:

| bool QCoreApplication::sendSpontaneousEvent | ( | QObject * | receiver, | |
| QEvent * | event | |||
| ) | [inline, static, private] |
Definition at line 185 of file qcoreapplication.h.
References event().
Referenced by QWidgetPrivate::close_helper(), QWidgetPrivate::hideChildren(), qt_sendSpontaneousEvent(), QApplication::setActiveWindow(), QWidgetPrivate::showChildren(), QETWidget::translateConfigEvent(), QETWidget::translateMouseEvent(), QETWidget::translatePropertyEvent(), QETWidget::translateWheelEvent(), Q3AccelManager::tryAccelEvent(), and QShortcutMap::tryShortcutEvent().
00186 { if (event) event->spont = true; return self ? self->notify(receiver, event) : false; }
Here is the call graph for this function:

| void QCoreApplication::init | ( | ) | [private] |
Definition at line 416 of file qcoreapplication.cpp.
References d, QCoreApplicationPrivate::eventDispatcher, QThread::initialize(), libraryPaths(), QObject::moveToThread(), QObject::parent(), qt_startup_hook(), self, and set_winapp_name().
Referenced by QCoreApplication().
00417 { 00418 Q_D(QCoreApplication); 00419 00420 #ifdef Q_OS_UNIX 00421 setlocale(LC_ALL, ""); // use correct char set mapping 00422 setlocale(LC_NUMERIC, "C"); // make sprintf()/scanf() work 00423 #endif 00424 00425 #ifdef Q_WS_WIN 00426 // Get the application name/instance if qWinMain() was not invoked 00427 set_winapp_name(); 00428 #endif 00429 00430 Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object"); 00431 QCoreApplication::self = this; 00432 00433 #ifndef QT_NO_THREAD 00434 QThread::initialize(); 00435 #endif 00436 00437 // use the event dispatcher created by the app programmer (if any) 00438 if (!QCoreApplicationPrivate::eventDispatcher) 00439 QCoreApplicationPrivate::eventDispatcher = d->threadData->eventDispatcher; 00440 // otherwise we create one 00441 if (!QCoreApplicationPrivate::eventDispatcher) 00442 d->createEventDispatcher(); 00443 Q_ASSERT(QCoreApplicationPrivate::eventDispatcher != 0); 00444 00445 if (!QCoreApplicationPrivate::eventDispatcher->parent()) 00446 QCoreApplicationPrivate::eventDispatcher->moveToThread(d->threadData->thread); 00447 00448 d->threadData->eventDispatcher = QCoreApplicationPrivate::eventDispatcher; 00449 00450 #ifndef QT_NO_LIBRARY 00451 if (!coreappdata()->app_libpaths) { 00452 // make sure that library paths is initialized 00453 libraryPaths(); 00454 } else { 00455 d->appendApplicationPathToLibraryPaths(); 00456 } 00457 #endif 00458 00459 #if defined(Q_OS_UNIX) && !(defined(QT_NO_PROCESS)) 00460 // Make sure the process manager thread object is created in the main 00461 // thread. 00462 QProcessPrivate::initializeProcessManager(); 00463 #endif 00464 00465 #ifdef QT_EVAL 00466 extern void qt_core_eval_init(uint); 00467 qt_core_eval_init(d->application_type); 00468 #endif 00469 00470 qt_startup_hook(); 00471 }
Here is the call graph for this function:

friend class QEventDispatcherUNIXPrivate [friend] |
Definition at line 170 of file qcoreapplication.h.
friend class QApplication [friend] |
friend class QApplicationPrivate [friend] |
friend class QETWidget [friend] |
Definition at line 173 of file qcoreapplication.h.
friend class Q3AccelManager [friend] |
Definition at line 174 of file qcoreapplication.h.
friend class QShortcutMap [friend] |
Definition at line 175 of file qcoreapplication.h.
friend class QWidget [friend] |
friend class QWidgetPrivate [friend] |
Definition at line 177 of file qcoreapplication.h.
Definition at line 4185 of file qapplication_x11.cpp.
04186 { 04187 return QCoreApplication::sendSpontaneousEvent(receiver, event); 04188 }
| Q_CORE_EXPORT QString qAppName | ( | ) | [friend] |
Definition at line 306 of file qcoreapplication.cpp.
00307 { 00308 if (!QCoreApplicationPrivate::checkInstance("qAppName")) 00309 return QString(); 00310 return QCoreApplication::instance()->d_func()->appName(); 00311 }
| void qAddPostRoutine | ( | QtCleanUpFunction | ptr | ) | [related] |
Adds a global routine that 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 should return nothing. For example:
static int *global_ptr = 0; static void cleanup_ptr() { delete [] global_ptr; global_ptr = 0; } void init_ptr() { global_ptr = new int[100]; // allocate data qAddPostRoutine(cleanup_ptr); // delete later }
Note that for an application- or module-wide cleanup, qAddPostRoutine() 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 Qt's 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 { 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; };
By selecting the right parent object, this can often be made to clean up the module's data at the right moment.
Definition at line 100 of file qcoreapplication.cpp.
Referenced by build_scale_table(), clipboardData(), d(), htmlMap(), qt_init_picture_handlers(), selectionData(), and setupOwner().
00101 { 00102 QVFuncList *list = postRList(); 00103 if (!list) 00104 return; 00105 list->prepend(p); 00106 }
QCoreApplication * QCoreApplication::self [static, private] |
Definition at line 168 of file qcoreapplication.h.
Referenced by arguments(), QCoreApplicationPrivate::checkInstance(), exec(), flush(), init(), QCoreApplicationPrivate::isTranslatorInstalled(), and translate().
1.5.1