⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qcoreapplication.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    \code        foreach (QString path, app.libraryPaths())            do_something(path);    \endcode    \sa setLibraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary,        {How to Create Qt Plugins}*/QStringList QCoreApplication::libraryPaths(){    QMutexLocker locker(libraryPathMutex());    if (!self)        return QStringList();    if (!coreappdata()->app_libpaths) {        QStringList *app_libpaths = coreappdata()->app_libpaths = new QStringList;        QString installPathPlugins =  QLibraryInfo::location(QLibraryInfo::PluginsPath);        if (QFile::exists(installPathPlugins)) {            // Make sure we convert from backslashes to slashes.            installPathPlugins = QDir(installPathPlugins).canonicalPath();            app_libpaths->append(installPathPlugins);        }        // If QCoreApplication is not yet instantiated,        // make sure we add the application path when we construct the QCoreApplication        if (self) self->d_func()->appendApplicationPathToLibraryPaths();        const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");        if (!libPathEnv.isEmpty()) {#ifdef Q_OS_WIN            QChar pathSep(';');#else            QChar pathSep(':');#endif            QStringList paths = QString::fromLatin1(libPathEnv).split(pathSep, QString::SkipEmptyParts);            for (QStringList::iterator it = paths.begin(); it != paths.end(); ++it) {                app_libpaths->append(QDir(*it).canonicalPath());            }        }    }    return *(coreappdata()->app_libpaths);}/*!  Sets the list of directories to search when loading libraries to \a paths.  All existing paths will be deleted and the path list will consist of the  paths given in \a paths.  \sa libraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary */void QCoreApplication::setLibraryPaths(const QStringList &paths){    *(coreappdata()->app_libpaths) = paths;}/*!  Appends \a path to the end of the library path list. If \a 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 \c INSTALL/plugins, where \c INSTALL is the directory where Qt was  installed.  \sa removeLibraryPath(), libraryPaths(), setLibraryPaths() */void QCoreApplication::addLibraryPath(const QString &path){    if (path.isEmpty())        return;    // make sure that library paths is initialized    libraryPaths();    QString canonicalPath = QDir(path).canonicalPath();    if (!coreappdata()->app_libpaths->contains(canonicalPath))        coreappdata()->app_libpaths->prepend(canonicalPath);}/*!    Removes \a path from the library path list. If \a path is empty or not    in the path list, the list is not changed.    \sa addLibraryPath(), libraryPaths(), setLibraryPaths()*/void QCoreApplication::removeLibraryPath(const QString &path){    if (path.isEmpty())        return;    // make sure that library paths is initialized    libraryPaths();    coreappdata()->app_libpaths->removeAll(path);}#endif //QT_NO_LIBRARY/*!    \typedef QCoreApplication::EventFilter    A function with the following signature that can be used as an    event filter:    \code        bool myEventFilter(void *message, long *result);    \endcode    \sa setEventFilter()*//*!    \fn EventFilter QCoreApplication::setEventFilter(EventFilter filter)    Sets the event filter \a 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 \e 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).    \sa installEventFilter()*/QCoreApplication::EventFilterQCoreApplication::setEventFilter(QCoreApplication::EventFilter filter){    Q_D(QCoreApplication);    EventFilter old = d->eventFilter;    d->eventFilter = filter;    return old;}/*!    Sends \a 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 \a result parameter.    \sa setEventFilter()*/bool QCoreApplication::filterEvent(void *message, long *result){    Q_D(QCoreApplication);    if (result)        *result = 0;    if (d->eventFilter)        return d->eventFilter(message, result);#ifdef Q_OS_WIN    return winEventFilter(reinterpret_cast<MSG *>(message), result);#else    return false;#endif}/*!    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().    \sa QAbstractEventDispatcher::hasPendingEvents()*/bool QCoreApplication::hasPendingEvents(){    QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();    if (eventDispatcher)        return eventDispatcher->hasPendingEvents();    return false;}#ifdef QT3_SUPPORT/*! \fn void QCoreApplication::lock()    In Qt 3, this function locked the Qt library mutex, allowing    non-GUI threads to perform basic printing operations using    QPainter.    In Qt 4, this is no longer supported, since painting is only    supported from within a paint event handler. This function does    nothing.    \sa QWidget::paintEvent()*//*! \fn void QCoreApplication::unlock(bool wakeUpGui)    In Qt 3, this function unlocked the Qt library mutex. The mutex    allowed non-GUI threads to perform basic printing operations    using QPainter.    In Qt 4, this is no longer supported, since painting is only    supported from within a paint event handler. This function does    nothing.*//*! \fn bool QCoreApplication::locked()    This function does nothing. It is there to keep old code working.    It always returns false.    See lock() for details.*//*! \fn bool QCoreApplication::tryLock()    This function does nothing. It is there to keep old code working.    It always returns false.    See lock() for details.*//*! \fn void QCoreApplication::processOneEvent()    \obsolete    Waits for an event to occur, processes it, then returns.    This function is useful for adapting Qt to situations where the    event processing must be grafted onto existing program loops.    Using this function in new applications may be an indication of design    problems.    \sa processEvents(), exec(), QTimer*//*! \obsolete    This function enters the main event loop (recursively). Do not call    it unless you really know what you are doing.*/int QCoreApplication::enter_loop(){    QThread *currentThread = QThread::currentThread();    if (currentThread != mainThread()) {        qWarning("QApplication::enter_loop() failed: must be called from the main thread.");        return -1;    }    QEventLoop eventLoop;    int returnCode = eventLoop.exec();    return returnCode;}/*! \obsolete    This function exits from a recursive call to the main event loop.    Do not call it unless you are an expert.*/void QCoreApplication::exit_loop(){    QThread *currentThread = QThread::currentThread();    if (currentThread != mainThread()) {        qWarning("QApplication::exit_loop() failed: must be called from the main thread.");        return;    }    QThreadData *data = QThreadData::get(currentThread);    if (!data->eventLoops.isEmpty())        data->eventLoops.top()->exit();}/*! \obsolete    Returns the current loop level.*/int QCoreApplication::loopLevel(){    QThread *thr = mainThread();    if (!thr)        return -1;    QThreadData *data = QThreadData::get(thr);    return data->eventLoops.size();}#endif/*!    \fn void QCoreApplication::watchUnixSignal(int signal, bool watch)    \internal*//*!    \fn void QCoreApplication::unixSignal(int number)    \internal    This signal is emitted whenever a Unix signal is received by the    application. The Unix signal received is specified by its \a number.*//*!    \fn void qAddPostRoutine(QtCleanUpFunction ptr)    \relates QCoreApplication    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 \a ptr should take no arguments and should    return nothing. For example:    \code        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        }    \endcode    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:    \code        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;        };    \endcode    By selecting the right parent object, this can often be made to    clean up the module's data at the right moment.*//*!    \macro Q_DECLARE_TR_FUNCTIONS(context)    \relates QCoreApplication    The Q_DECLARE_TR_FUNCTIONS() macro declares and implements two    translation functions, \c tr() and \c trUtf8(), with these    signatures:    \code        static inline QString tr(const char *sourceText,                                 const char *comment = 0);        static inline QString trUtf8(const char *sourceText,                                     const char *comment = 0);    \endcode    This macro is useful if you want to use QObject::tr() or    QObject::trUtf8() in classes that don't inherit from QObject.    Q_DECLARE_TR_FUNCTIONS() must appear at the very top of the    class definition (before the first \c{public:} or \c{protected:}).    For example:    \code        class MyMfcView : public CView        {            Q_DECLARE_TR_FUNCTIONS(MyMfcView)        public:            MyMfcView();            ...        };    \endcode    The \e context parameter is normally the class name.    \sa Q_OBJECT, QObject::tr(), QObject::trUtf8()*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -