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

📄 qapplication.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 5 页
字号:
See 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..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 "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 at \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 reciever 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 "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 your application allocates colors when run on a display with a limited amount of colors, i.e. 8 bit / 256 color displays..PPThe color specification must be set before you create the QApplication object..PPThe choices are:.TPQApplication::NormalColor. This is the default color allocation strategy. Use this choice if your application uses buttons, menus, texts and pixmaps with few colors. With this choice, 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 choice if your application needs a small number of custom colors. On X11, this choice is the same as NormalColor. On Windows, Qt creates a Windows palette, and allocates colors to it on demand..TPQApplication::ManyColor. Use this choice if your application is very color hungry (e.g. it wants 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", 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 by 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 see what mode you end up with, you can call QColor::numBitPlanes() once the QApplication object exists. A value greater than 8 (typically 16, 24 or 32) means true color..PPThe color cube used by Qt has all those colors with red, green, and blue components of either 0x00, 0x33, 0x66, 0x99, 0xCC, or 0xFF..PPSee also colorSpec(), QColor::numBitPlanes() and QColor::enterAllocContext()..PPExamples:.)l helpviewer/main.cpp, showimg/main.cpp, t9/main.cpp, tetrix/tetrix.cpp and themes/main.cpp..SH "void QApplication::setCursorFlashTime ( int msecs )\fC [static]\fR"Sets the text cursor's flash time to \fImsecs\fR milliseconds. The flash time is the time required to display, invert and restore the caret display: A full flash cycle. 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 )"Sets the default codec of the application to \fIcodec\fR..PPIf the literal quoted text in the program is not in the Latin1 encoding, this function can be used to set the appropriate encoding. For example, software developed by Korean programmers might use eucKR for all the text in the program, in which case the main() function might look like this:.PP.nf.br    int main(int argc, char** argv).br    {.br        QApplication app(argc, argv);.br        ... install any additional codecs ...

⌨️ 快捷键说明

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