qapplication.3qt

来自「qt-x11-free-3.0.3.tar.gz minigui图形界面工具」· 3QT 代码 · 共 1,507 行 · 第 1/5 页

3QT
1,507
字号
See 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 when the GUI thread is about to process a cycle of the event loop..PPSee also wakeUpGuiThread()..SH "bool QApplication::hasGlobalMouseTracking ()\fC [static]\fR"Returns TRUE if global mouse tracking is enabled, otherwise FALSE..PPSee also setGlobalMouseTracking()..SH "bool QApplication::hasPendingEvents ()"This function returns TRUE if there are pending events, and returns FALSE if there are not. 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 FALSE..PPBy default, Qt will try to use the desktop settings, and setDesktopSettingsAware() must be called 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..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, application/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. Returns \fC$QTDIR/plugins\fR as the only entry if no paths have been set..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 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() and locked()..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 differing implementations of recursive mutexes on supported platforms, calling this function from the same thread that previous locked the mutex will give undefined results..PPSee also lock() and unlock()..SH "int QApplication::loopLevel () const"Returns the current loop level.PPSee also enter_loop() and exit_loop()..SH "bool QApplication::macEventFilter ( 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, or return FALSE for normal event dispatching..SH "QWidget * QApplication::mainWidget () const"Returns the main application widget, or a null pointer if there is not a defined 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)..PPReimplementing this virtual function is one of five ways to process an event: <ol type=1>.TPReimplementing this function. Very powerful, you get complete control, but of course only one subclass can be qApp..IP.TPInstalling an event filter on qApp. Such an event filter gets to process all events for all widgets, so it's just as powerful as reimplementing notify(), and in this way it's possible to have more than one application-global event filter. Global event filters get to see even mouse events for disabled widgets, and if global mouse tracking is enabled, 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 even filter gets all the events except Tab and Shift-Tab key presses..IP.TPFinally, reimplementing paintEvent(), mousePressEvent() and so on. This is the normal, 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"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(), QThread::postEvent() 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() and QTimer..PPExample: fileiconview/qfileiconview.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() and QTimer..SH "void QApplication::processOneEvent ()"Waits 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 into 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, qwerty/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, or 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 "bool QApplication::remoteControlEnabled () const"Returns TRUE if remote control access is enabled for the application; otherwise returns FALSE..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"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()..PPExample: showimg/showimg.cpp..SH "bool QApplication::reverseLayout ()\fC [static]\fR"Returns TRUE if all dialogs and widgets will be laid out in a mirrored fashion..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 a text editor this would mean creating a temporary file that includes the current contents of the 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\fBImportant\fR.brWithin 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.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()..SH "void QApplication::sendPostedEvents ()\fC [static]\fR"Dispatches all posted events, i.e. empties the event queue. This is an overloaded member function, provided for convenience. It behaves essentially like the above function..SH "QString QApplication::sessionId () const"Returns the identifier of the current session..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(), 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.

⌨️ 快捷键说明

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