qapplication.3qt
来自「Linux下的基于X11的图形开发环境。」· 3QT 代码 · 共 1,456 行 · 第 1/5 页
3QT
1,456 行
.PPSee also flushX(), sendPostedEvents(), and QPainter::flush()..SH "void QApplication::flushX ()\fC [static]\fR"Flushes the X event queue in the X11 implementation. This normally returns almost immediately. Does nothing on other platforms..PPSee also syncX()..PPExample: xform/xform.cpp..SH "QWidget * QApplication::focusWidget () const"Returns the application widget that has the keyboard input focus, or 0 if no widget in this application has the focus..PPSee also QWidget::setFocus(), QWidget::focus, and activeWindow()..SH "QFont QApplication::font ( const QWidget * w = 0 )\fC [static]\fR"Returns the default font for the widget \fIw\fR, or the default application font if \fIw\fR is 0..PPSee also setFont(), fontMetrics(), and QWidget::font..PPExamples:.)l qfd/fontdisplayer.cpp, themes/metal.cpp, and themes/themes.cpp..SH "QFontMetrics QApplication::fontMetrics ()\fC [static]\fR"Returns display (screen) font metrics for the application font..PPSee also font(), setFont(), QWidget::fontMetrics(), and QPainter::fontMetrics()..SH "QSize QApplication::globalStrut ()\fC [static]\fR"Returns the application's global strut..PPThe strut is a size object whose dimensions are the minimum that any GUI element that the user can interact with should have. For example no button should be resized to be smaller than the global strut size..PPSee also setGlobalStrut()..SH "void QApplication::guiThreadAwake ()\fC [signal]\fR"This signal is emitted after the event loop returns from a function that could block..PPSee also wakeUpGuiThread()..SH "bool QApplication::hasGlobalMouseTracking ()\fC [static]\fR"Returns TRUE if global mouse tracking is enabled; otherwise returns FALSE..PPSee also setGlobalMouseTracking()..SH "bool QApplication::hasPendingEvents ()"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 QApplication::postEvent()..SH "int QApplication::horizontalAlignment ( int align )\fC [static]\fR"Strips out vertical alignment flags and transforms an alignment \fIalign\fR of AlignAuto into AlignLeft or AlignRight according to the language used. The other horizontal alignment flags are left untouched..SH "void QApplication::installTranslator ( QTranslator * mf )"Adds the message file \fImf\fR to the list of message files to be used for translations..PPMultiple message files can be installed. Translations are searched for in the last installed message file, then the one from last, and so on, back to the first installed message file. The search stops as soon as a matching translation is found..PPSee also removeTranslator(), translate(), and QTranslator::load()..PPExample: i18n/main.cpp..SH "bool QApplication::isEffectEnabled ( Qt::UIEffect effect )\fC [static]\fR"Returns TRUE if \fIeffect\fR is enabled; otherwise returns FALSE..PPBy default, Qt will try to use the desktop settings. Call setDesktopSettingsAware(FALSE) to prevent this..PPSee also setEffectEnabled() and Qt::UIEffect..SH "bool QApplication::isSessionRestored () const"Returns TRUE if the application has been restored from an earlier session; otherwise returns FALSE..PPSee also sessionId(), commitData(), and saveState()..SH "void QApplication::lastWindowClosed ()\fC [signal]\fR"This signal is emitted when the user has closed the last top level window..PPThe signal is very useful when your application has many top level widgets but no main widget. You can then connect it to the quit() slot..PPFor convenience, this signal is \fInot\fR emitted for transient top level widgets such as popup menus and dialogs..PPSee also mainWidget(), topLevelWidgets(), QWidget::isTopLevel, and QWidget::close()..PPExamples:.)l action/main.cpp, addressbook/main.cpp, extension/main.cpp, helpviewer/main.cpp, mdi/main.cpp, qwerty/main.cpp, and showimg/main.cpp..SH "QStringList QApplication::libraryPaths ()\fC [static]\fR"Returns a list of paths that the application will search when dynamically loading libraries. The installation directory for plugins is the only entry if no paths have been set. The default installation directory for plugins is \fCINSTALL/plugins\fR, where \fCINSTALL\fR is the directory where Qt was installed. On Windows, the directory of the application executable (NOT the working directory) is also added to the plugin paths..PPIf you want to iterate over the list, you should iterate over a copy, e.g..PP.nf.br QStringList list = app.libraryPaths();.br QStringList::Iterator it = list.begin();.br while( it != list.end() ) {.br myProcessing( *it );.br ++it;.br }.br.fi.PPSee the plugins documentation for a description of how the library paths are used..PPSee also setLibraryPaths(), addLibraryPath(), removeLibraryPath(), and QLibrary..SH "void QApplication::lock ()"Lock the Qt Library Mutex. If another thread has already locked the mutex, the calling thread will block until the other thread has unlocked the mutex..PPSee also unlock(), locked(), and Thread Support in Qt..SH "bool QApplication::locked ()"Returns TRUE if the Qt Library Mutex is locked by a different thread; otherwise returns FALSE..PP\fBWarning:\fR Due to different implementations of recursive mutexes on the supported platforms, calling this function from the same thread that previously locked the mutex will give undefined results..PPSee also lock(), unlock(), and Thread Support in Qt..SH "int QApplication::loopLevel () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns the current loop level..SH "bool QApplication::macEventFilter ( EventHandlerCallRef, EventRef )\fC [virtual]\fR"This virtual function is only implemented under Macintosh..PPIf you create an application that inherits QApplication and reimplement this function, you get direct access to all Carbon Events that are received from the MacOS..PPReturn TRUE if you want to stop the event from being processed. Return FALSE for normal event dispatching..SH "QWidget * QApplication::mainWidget () const"Returns the main application widget, or 0 if there is no main widget..PPSee also setMainWidget()..SH "bool QApplication::notify ( QObject * receiver, QEvent * e )\fC [virtual]\fR"Sends event \fIe\fR to \fIreceiver\fR: \fIreceiver\fR->event(\fIe\fR). Returns the value that is returned from the receiver's event handler..PPFor 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)..PPThere are five different ways that events can be processed; reimplementing this virtual function is just one of them. All five approaches are listed below: <ol type=1>.TPReimplementing this function. This is very powerful, providing complete control; but only one subclass can be qApp..IP.TPInstalling an event filter on qApp. 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, and if global mouse tracking is enabled, as well as mouse move events for all widgets..IP.TPReimplementing 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..IP.TPInstalling an event filter on the object. Such an event filter gets all the events except Tab and Shift-Tab key presses..IP.TPReimplementing paintEvent(), mousePressEvent() and so on. This is the commonest, easiest and least powerful way..PPSee also QObject::event() and installEventFilter()..SH "QCursor * QApplication::overrideCursor ()\fC [static]\fR"Returns the active application override cursor..PPThis function returns 0 if no application cursor has been defined (i.e. the internal cursor stack is empty)..PPSee also setOverrideCursor() and restoreOverrideCursor()..SH "QPalette QApplication::palette ( const QWidget * w = 0 )\fC [static]\fR"Returns a pointer to the default application palette. There is always an application palette, i.e. the returned pointer is guaranteed to be non-null..PPIf a widget is passed in \fIw\fR, the default palette for the widget's class is returned. This may or may not be the application palette. In most cases there isn't a special palette for certain types of widgets, but one notable exception is the popup menu under Windows, if the user has defined a special background color for menus in the display settings..PPSee also setPalette() and QWidget::palette..PPExamples:.)l desktop/desktop.cpp, themes/metal.cpp, and themes/wood.cpp..SH "void QApplication::polish ( QWidget * w )\fC [virtual]\fR"Initialization of the appearance of the widget \fIw\fR \fIbefore\fR it is first shown..PPUsually widgets call this automatically when they are polished. It may be used to do some style-based central customization of widgets..PPNote that you are not limited to the public functions of QWidget. Instead, based on meta information like QObject::className() you are able to customize any kind of widget..PPSee also QStyle::polish(), QWidget::polish(), setPalette(), and setFont()..SH "void QApplication::postEvent ( QObject * receiver, QEvent * event )\fC [static]\fR"\fBNote:\fR This function is thread-safe when Qt is built withthread support.</p> Adds the event \fIevent\fR with the object \fIreceiver\fR as the receiver of the event, to an event queue and returns immediately..PPThe 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..PPWhen control returns to the main event loop, all events that are stored in the queue will be sent using the notify() function..PPSee also sendEvent() and notify()..SH "void QApplication::processEvents ()"Processes pending events, for 3 seconds or until there are no more events to process, whichever is shorter..PPYou can call this function occasionally when your program is busy performing a long operation (e.g. copying a file)..PPSee also exec(), QTimer, and QEventLoop::processEvents()..PPExamples:.)l fileiconview/qfileiconview.cpp and network/ftpclient/main.cpp..SH "void QApplication::processEvents ( int maxtime )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPProcesses pending events for \fImaxtime\fR milliseconds or until there are no more events to process, whichever is shorter..PPYou can call this function occasionally when you program is busy doing a long operation (e.g. copying a file)..PPSee also exec(), QTimer, and QEventLoop::processEvents()..SH "void QApplication::processOneEvent ()"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPWaits for an event to occur, processes it, then returns..PPThis function is useful for adapting Qt to situations where the event processing must be grafted onto existing program loops..PPUsing this function in new applications may be an indication of design problems..PPSee also processEvents(), exec(), and QTimer..SH "void QApplication::quit ()\fC [slot]\fR"Tells the application to exit with return code 0 (success). Equivalent to calling QApplication::exit( 0 )..PPIt's common to connect the lastWindowClosed() signal to quit(), and you also often connect e.g. QButton::clicked() or signals in QAction, QPopupMenu or QMenuBar to it..PPExample:.PP.nf.br QPushButton *quitButton = new QPushButton( "Quit" );.br connect( quitButton, SIGNAL(clicked()), qApp, SLOT(quit()) );.br.fi.PPSee also exit(), aboutToQuit(), lastWindowClosed(), and QAction..PPExamples:.)l addressbook/main.cpp, helpviewer/main.cpp, mdi/main.cpp, showimg/main.cpp, t2/main.cpp, t4/main.cpp, and t6/main.cpp..SH "QWSDecoration & QApplication::qwsDecoration ()\fC [static]\fR"Return the QWSDecoration used for decorating windows..PPThis method is non-portable. It is available \fIonly\fR in Qt/Embedded..PPSee also QWSDecoration..SH "bool QApplication::qwsEventFilter ( QWSEvent * )\fC [virtual]\fR"This virtual function is only implemented under Qt/Embedded..PPIf you create an application that inherits QApplication and reimplement this function, you get direct access to all QWS (Q Window System) events that the are received from the QWS master process..PPReturn TRUE if you want to stop the event from being processed. Return FALSE for normal event dispatching..SH "void QApplication::qwsSetCustomColors ( QRgb * colorTable, int start, int numColors )"Set Qt/Embedded custom color table..PPQt/Embedded on 8-bpp displays allocates a standard 216 color cube. The remaining 40 colors may be used by setting a custom color table in the QWS master process before any clients connect..PP\fIcolorTable\fR is an array of up to 40 custom colors. \fIstart\fR is the starting index (0-39) and \fInumColors\fR is the number of colors to be set (1-40)..PPThis method is non-portable. It is available \fIonly\fR in Qt/Embedded..SH "void QApplication::qwsSetDecoration ( QWSDecoration * d )\fC [static]\fR"Set the QWSDecoration derived class to use for decorating the Qt/Embedded windows to \fId\fR..PPThis method is non-portable. It is available \fIonly\fR in Qt/Embedded..PPSee also QWSDecoration..SH "void QApplication::removeLibraryPath ( const QString & path )\fC [static]\fR"Removes \fIpath\fR from the library path list. If \fIpath\fR is empty or not in the path list, the list is not changed..PPSee also addLibraryPath(), libraryPaths(), and setLibraryPaths()..SH "void QApplication::removePostedEvents ( QObject * receiver )\fC [static]\fR"\fBNote:\fR This function is thread-safe when Qt is built withthread support.</p> Removes all events posted using postEvent() for \fIreceiver\fR..PPThe events are \fInot\fR 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 \fIreceiver\fR to break one or more invariants..SH "void QApplication::removeTranslator ( QTranslator * mf )"Removes the message file \fImf\fR from the list of message files used by this application. (It does not delete the message file from the file system.).PPSee also installTranslator(), translate(), and QObject::tr()..PPExample: i18n/main.cpp..SH "void QApplication::restoreOverrideCursor ()\fC [static]\fR"Undoes the last setOverrideCursor()..PPIf setOverrideCursor() has been called twice, calling restoreOverrideCursor() will activate the first cursor set. Calling this function a second time restores the original widgets' cursors..PPSee also setOverrideCursor() and overrideCursor()..PPExamples:.)l network/ftpclient/ftpmainwindow.ui.h and showimg/showimg.cpp..SH "bool QApplication::reverseLayout ()\fC [static]\fR"Returns TRUE if all dialogs and widgets will be laid out in a mirrored (right to left) fashion. Returns FALSE if dialogs and widgets will be laid out left to right..PPSee also setReverseLayout()..SH "void QApplication::saveState ( QSessionManager & sm )\fC [virtual]\fR"This function deals with session management. It is invoked when the session manager wants the application to preserve its state for a future session..PPFor example, a text editor would create a temporary file that includes the current contents of its edit buffers, the location of the cursor and other aspects of the current editing session..PPNote that you should never exit the application within this function. Instead, the session manager may or may not do this afterwards, depending on the context. Futhermore, most session managers will very likely request a saved state immediately after the application has been started. This permits the session manager to learn about the application's restart policy..PP\fBWarning:\fR Within this function, no user interaction is possible, \fIunless\fR you ask the session manager \fIsm\fR for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details..PPSee also isSessionRestored(), sessionId(), and commitData()..SH "bool QApplication::sendEvent ( QObject * receiver, QEvent * event )\fC [static]\fR"Sends event \fIevent\fR directly to receiver \fIreceiver\fR, using the notify() function. Returns the value that was returned from the event handler..PPThe event is \fInot\fR deleted when the event has been sent. The normal approach is to create the event on the stack, e.g..PP.nf.br QMouseEvent me( QEvent::MouseButtonPress, pos, 0, 0 );.br QApplication::sendEvent( mainWindow, &me );.br.fi
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?