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

📄 qapplication.3qt

📁 Trolltech公司发布的基于C++图形开发环境
💻 3QT
📖 第 1 页 / 共 5 页
字号:
See 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 distributor/distributor.ui.h, network/archivesearch/archivedialog.ui.h, 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(), commitData(), and the Session Management overview..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.fiIf you create the event on the heap you must delete it..PPSee also postEvent() and notify()..PPExample: popup/popup.cpp..SH "void QApplication::sendPostedEvents ( QObject * receiver, int event_type )\fC [static]\fR"Immediately dispatches all events which have been previously queued with QApplication::postEvent() and which are for the object \fIreceiver\fR and have the event type \fIevent_type\fR..PPNote that events from the window system are \fInot\fR dispatched by this function, but by processEvents()..PPIf \fIreceiver\fR is null, the events of \fIevent_type\fR are sent for all objects. If \fIevent_type\fR is 0, all the events are sent for \fIreceiver\fR..SH "void QApplication::sendPostedEvents ()\fC [static]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDispatches all posted events, i.e. empties the event queue..SH "QString QApplication::sessionId () const"Returns the current session's identifier..PPIf the application has been restored from an earlier session, this identifier is the same as it was in that previous session..PPThe session identifier is guaranteed to be unique both for different applications and for different instances of the same application..PPSee also isSessionRestored(), sessionKey(), commitData(), and saveState()..SH "QString QApplication::sessionKey () const"Returns the session key in the current session..PPIf the application has been restored from an earlier session, this key is the same as it was when the previous session ended..PPThe session key changes with every call of commitData() or saveState()..PPSee also isSessionRestored(), sessionId(), commitData(), and saveState()..SH "void QApplication::setColorSpec ( int spec )\fC [static]\fR"Sets the color specification for the application to \fIspec\fR..PPThe color specification controls how the application allocates colors when run on a display with a limited amount of colors, e.g. 8 bit / 256 color displays..PPThe color specification must be set before you create the QApplication object..PPThe options are:.TPQApplication::NormalColor. This is the default color allocation strategy. Use this option if your application uses buttons, menus, texts and pixmaps with few colors. With this option, the application uses system global colors. This works fine for most applications under X11, but on Windows machines it may cause dithering of non-standard colors..TPQApplication::CustomColor. Use this option if your application needs a small number of custom colors. On X11, this option is the same as NormalColor. On Windows, Qt creates a Windows palette, and allocates colors to it on demand..TPQApplication::ManyColor. Use this option if your application is very color hungry (e.g. it requires thousands of colors). Under X11 the effect is:.TPFor 256-color displays which have at best a 256 color true color visual, the default visual is used, and colors are allocated from a color cube. The color cube is the 6x6x6 (216 color) "Web palette"<sup>*</sup>, but the number of colors can be changed by the \fI-ncols\fR option. The user can force the application to use the true color visual with the -visual option..TPFor 256-color displays which have a true color visual with more than 256 colors, use that visual. Silicon Graphics X servers have this feature, for example. They provide an 8 bit visual by default but can deliver true color when asked. On Windows, Qt creates a Windows palette, and fills it with a color cube..PPBe aware that the CustomColor and ManyColor choices may lead to colormap flashing: The foreground application gets (most) of the available colors, while the background windows will look less attractive..PPExample:.PP.nf.br  int main( int argc, char **argv ).br  {.br      QApplication::setColorSpec( QApplication::ManyColor );.br      QApplication a( argc, argv );.br      ....br  }.br.fi.PPQColor provides more functionality for controlling color allocation and freeing up certain colors. See QColor::enterAllocContext() for more information..PPTo check what mode you end up with, call QColor::numBitPlanes() once the QApplication object exists. A value greater than 8 (typically 16, 24 or 32) means true color..PP<sup>*</sup> The color cube used by Qt has 216 colors whose red, green, and blue components always have one of the following values: 0x00, 0x33, 0x66, 0x99, 0xCC, or 0xFF..PPSee also colorSpec(), QColor::numBitPlanes(), and QColor::enterAllocContext()..PPExamples:.)l helpviewer/main.cpp, opengl/main.cpp, showimg/main.cpp, t9/main.cpp, tetrax/tetrax.cpp, tetrix/tetrix.cpp, and themes/main.cpp..SH "void QApplication::setCursorFlashTime ( int msecs )\fC [static]\fR"Sets the text cursor's flash (blink) time to \fImsecs\fR milliseconds. The flash time is the time required to display, invert and restore the caret display. Usually the text cursor is displayed for \fImsecs/2\fR milliseconds, then hidden for \fImsecs/2\fR milliseconds, but this may vary..PPNote that on Microsoft Windows, calling this function sets the cursor flash time for all windows..PPSee also cursorFlashTime()..SH "void QApplication::setDefaultCodec ( QTextCodec * codec )"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPThis is the same as QTextCodec::setCodecForTr()..SH "void QApplication::setDesktopSettingsAware ( bool on )\fC [static]\fR"By default, Qt will try to use the current standard colors, fonts etc., from the underlying window system's desktop settings, and use them for all relevant widgets. This behavior can be switched off by calling this function with \fIon\fR set to FALSE..PPThis static function must be called before creating the QApplication object, like this:.PP.nf.br  int main( int argc, char** argv ) {.br    QApplication::setDesktopSettingsAware( FALSE ); // I know better than the user.br    QApplication myApp( argc, argv ); // Use default fonts & colors.br    ....br  }.br.fi.PPSee also desktopSettingsAware()..SH "void QApplication::setDoubleClickInterval ( int ms )\fC [static]\fR"Sets the time limit that distinguishes a double click from two consecutive mouse clicks to \fIms\fR milliseconds..PPNote that on Microsoft Windows, calling this function sets the double click interval for all windows..PPSee also doubleClickInterval()..SH "void QApplication::setEffectEnabled ( Qt::UIEffect effect, bool enable = TRUE )\fC [static]\fR"Enables the UI effect \fIeffect\fR if \fIenable\fR is TRUE, otherwise the effect will not be used..PPNote: All effects are disabled on screens running at less than 16-bit color depth..PPSee also isEffectEnabled(), Qt::UIEffect, and setDesktopSettingsAware()..SH "void QApplication::setFont ( const QFont & font, bool informWidgets = FALSE, const char * className = 0 )\fC [static]\fR"Changes the default application font to \fIfont\fR. If \fIinformWidgets\fR is TRUE, then existing widgets are informed about the change and may adjust themselves to the new application setting. If \fIinformWidgets\fR is FALSE, the change only affects newly created widgets. If \fIclassName\fR is passed, the change applies only to classes that inherit \fIclassName\fR (as reported by QObject::inherits())..PPOn application start-up, the default font depends on the window system. It can vary depending on both the window system version and the locale. This function lets you override the default font; but overriding may be a bad idea because, for example, some locales need extra-large fonts to support their special characters..PPSee also font(), fontMetrics(), and QWidget::font..PPExamples:.)l desktop/desktop.cpp, themes/metal.cpp, and themes/themes.cpp..SH "void QApplication::setGlobalMouseTracking ( bool enable )\fC [static]\fR"Enables global mouse tracking if \fIenable\fR is TRUE, or disables it if \fIenable\fR is FALSE..PPEnabling global mouse tracking makes it possible for widget event filters or application event filters to get all mouse move events, even when no button is depressed. This is useful for special GUI elements, e.g. tooltips..PPGlobal mouse tracking does not affect widgets and their mouseMoveEvent(). For a widget to get mouse move events when no button is depressed, it must do QWidget::setMouseTracking(TRUE)..PPThis function uses an internal counter. Each setGlobalMouseTracking(TRUE) must have a corresponding setGlobalMouseTracking(FALSE):.PP.nf.br        // at this point global mouse tracking is off.br        QApplication::setGlobalMouseTracking( TRUE );.br        QApplication::setGlobalMouseTracking( TRUE );.br        QApplication::setGlobalMouseTracking( FALSE );.br        // at this point it's still on.br        QApplication::setGlobalMouseTracking( FALSE );.br        // but now it's off.br.fi.PPSee also hasGlobalMouseTracking() and QWidget::mouseTracking..SH "void QApplication::setGlobalStrut ( const QSize & strut )\fC [static]\fR"Sets the application's global strut to \fIstrut\fR..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..PPThe strut size should be considered when reimplementing GUI controls that may be used on touch-screens or similar IO-devices..PPExample:.PP.nf.br  QSize& WidgetClass::sizeHint() const.br  {.br      return QSize( 80, 25 ).expandedTo( QApplication::globalStrut() );.br  }.br.fi.PPSee also globalStrut()..SH "void QApplication::setLibraryPaths ( const QStringList & paths )\fC [static]\fR"Sets the list of directories to search when loading libraries to \fIpaths\fR. All existing paths will be deleted and the path list will consist of the paths given in \fIpaths\fR..PPSee also libraryPaths(), addLibraryPath(), removeLibraryPath(), and QLibrary..SH "void QApplication::setMainWidget ( QWidget * mainWidget )\fC [virtual]\fR"Sets the application's main widget to \fImainWidget\fR..PPIn most respects the main widget is like any other widget, except that if it is closed, the application exits. Note that QApplication does \fInot\fR take ownership of the \fImainWidget\fR, so if you create your main widget on the heap you must delete it yourself..PPYou need not have a main widget; connecting lastWindowClosed() to quit() is an alternative..PPFor X11, this function also resizes and moves the main widget according to the \fI-geometry\fR command-line option, so you should set the default geometry (using QWidget::setGeometry()) before calling setMainWidget()..PPSee also mainWidget(), exec(), and quit()..PPExamples:.)l chart/main.cpp, helpsystem/main.cpp, life/main.cpp, network/ftpclient/main.cpp, opengl/main.cpp, t1/main.cpp, and t4/main.cpp..SH "void QApplication::setOverrideCursor ( const QCursor & cursor, bool replace = FALSE )\fC [static]\fR"Sets the application override cursor to \fIcursor\fR..PPApplication override cursors are intended for showing the user that the application is in a special state, for example during an operation that might take some time..PPThis cursor will be displayed in all the application's widgets until restoreOverrideCursor() or another setOverrideCursor() is called..PPApplication cursors are stored on an internal stack. setOverrideCursor() pushes the cursor onto the stack, and restoreOverrideCursor() pops the active cursor off the stack. Every setOverrideCursor() must eventually be followed by a corresponding restoreOverrideCursor(), otherwise the stack will never be emptied..PPIf \fIreplace\fR is TRUE, the new cursor will replace the last override cursor (the stack keeps its depth). If \fIreplace\fR is FALSE, the new stack is pushed onto the top of the stack..PPExample:.PP.nf.br        QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );.br        calculateHugeMandelbrot();              // lunch time....br        QApplication::restoreOverrideCursor();.br.fi.PPSee also overrideCursor(), restoreOverrideCursor(), and QWidget::cursor..PPExamples:.)l distributor/distributor.ui.h, network/archivesearch/archivedialog.ui.h, network/ftpclient/ftpmainwindow.ui.h, and showimg/showimg.cpp..SH "void QApplication::setPalette ( const QPalette & palette, bool informWidgets = FALSE, const char * className = 0 )\fC [static]\fR"Changes the default application palette to \fIpalette\fR. If \fIinformWidgets\fR is TRUE, then existing widgets are informed about the change and may adjust themselves to the new application setting. If \fIinformWidgets\fR is FALSE, the change only affects newly created widgets..PPIf \fIclassName\fR is passed, the change applies only to widgets that inherit \fIclassName\fR (as reported by QObject::inherits()). If \fIclassName\fR is left 0, the change affects all widgets, thus overriding any previously set class specific palettes..PPThe palette may be changed according to the current GUI style in QStyle::polish()..PPSee also QWidget::palette, palette(), and QStyle::polish()..PPExamples:.)l i18n/main.cpp, themes/metal.cpp, themes/themes.cpp, and themes/wood.cpp..SH "void QApplication::setReverseLayout ( bool b )\fC [static]\fR"If \fIb\fR is TRUE, all dialogs and widgets will be laid out in a mirrored fashion, as required by right to left languages such as Arabic and Hebrew. If \fIb\fR is FALSE, dialogs and widgets are laid out left to right..PPChanging this flag in runtime does not cause a relayout of already instantiated widgets..PPSee also reverseLayo

⌨️ 快捷键说明

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