📄 qapplication.3qt
字号:
.PPSets the color used to mark selections in windows style for all widgets in the application. Will repaint all widgets if the color is changed..PPThe default color is \fCdarkBlue.\fR.PPSee also: winStyleHighlightColor()..SH "bool QApplication::startingUp () \fC[static]\fR"Returns TRUE if an application object has not been created yet..PPSee also: closingDown()..SH "QStyle& QApplication::style () \fC[static]\fR"Returns the style object of the application..PPSee also: setStyle() and QStyle..SH "void QApplication::syncX () \fC[static]\fR"Synchronizes with the X server in the X11 implementation. Does nothing on other platforms..PPSee also: flushX()..SH "QWidgetList * QApplication::topLevelWidgets () \fC[static]\fR"Returns a list of the top level widgets in the application..PPThe list is created using new and must be deleted by the caller..PPThe list is empty if there are no top level widgets..PPNote that some of the top level widgets may be hidden, for example all the popup menus of a menubar..PPExample:.PP.nf.br //.br // Shows all hidden top level widgets..br //.br QWidgetList *list = QApplication::topLevelWidgets();.br QWidgetListIt it( *list ); // iterate over the widgets.br while ( it.current() ) { // for each top level widget....br if ( !it.current()->isVisible() ).br it.current()->show();.br ++it;.br }.br delete list; // delete the list, not the widgets.fi.PPThe QWidgetList class is defined in the qwidcoll.h header file..PP\fBWarning:\fR Delete the list away as soon you have finished using it. You can get in serious trouble if you for instance try to access a widget that has been deleted..PPSee also: allWidgets(), QWidget::isTopLevel(), QWidget::isVisible() and QList::isEmpty()..SH "QString QApplication::translate ( const char * scope, const char * key ) const"Returns the best available translation for \fIkey\fR in \fIscope,\fR by querying the installed messages files. The message file that was installed last is asked first..PPQObject::tr() offers a more convenient way to use this functionality..PP\fIscope\fR is typically a class name (e.g. \fCMyDialog)\fR and \fIis\fR either English text or a short marker text, if the output text will be very long (as for help texts)..PPIf none of the message files contain a translation for \fIkey\fR in \fIscope,\fR this function returns \fIkey.\fR.PPThis function is not virtual, but you can add alternative translation techniques by installing subclasses of QTranslator..PPSee also: QObject::tr(), installTranslator(), removeTranslator() and QTranslator..SH "QWidget * QApplication::widgetAt ( int x, int y, bool child=FALSE ) \fC[static]\fR"Returns a pointer to the widget at global screen position \fI(x,y),\fR or a null pointer if there is no Qt widget there..PPIf \fIchild\fR is FALSE and there is a child widget at position \fI(x,y),\fR the top-level widget containing it is returned. If \fIchild\fR is TRUE the child widget at position \fI(x,y)\fR is returned..PPSee also: QCursor::pos(), QWidget::grabMouse() and QWidget::grabKeyboard()..SH "QWidget * QApplication::widgetAt ( const QPoint & pos, bool child=FALSE ) \fC[static]\fR"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "const QColor& QApplication::winStyleHighlightColor () \fC[static]\fR"\fBThis function is obsolete.\fR It is provided to keep old programs working. We strongly advise against using it in new code..PPReturns the color used to mark selections in windows style..PPSee also: setWinStyleHighlightColor()..SH RELATED FUNCTION DOCUMENTATION.SH "void CHECK_PTR (void * p)"If \fIp\fR is null, a fatal messages says that the program ran out of memory and exits. If \fIp\fR is not null, nothing happens..PPThis is really a macro defined in qglobal.h..PPExample:.PP.nf.br int *a;.br CHECK_PTR( a = new int[80] ); // never do this!.br // do this instead:.br a = new int[80];.br CHECK_PTR( a ); // this is fine.fi.PPSee also: fatal() and Debugging.SH "Q_EXPORT void qWarning (const char * msg, ...)"Prints a warning message, or calls the message handler (if it has been installed)..PPThis function takes a format string and a list of arguments, similar to the C printf() function..PPExample:.PP.nf.br void f( int c ).br {.br if ( c > 200 ).br qWarning( "f: bad argument, c == %d", c );.br }.fi.PPUnder X11, the text is printed to stderr. Under Windows, the text is sent to the debugger..PP\fBWarning:\fR The internal buffer is limited to 512 bytes (including the 0-terminator)..PPSee also: debug(), fatal(), qInstallMsgHandler() and Debugging.PPExamples:.(lprogress/progress.cpp tictac/main.cpp.)l.SH "void ASSERT (bool test)"Prints a warning message containing the source code file name and line number if \fItest\fR is FALSE..PPThis is really a macro defined in qglobal.h..PPASSERT is useful for testing required conditions in your program..PPExample:.PP.nf.br //.br // File: div.cpp.br //.br.br #include <qglobal.h>.br.br int divide( int a, int b ).br {.br ASSERT( b != 0 ); // this is line 9.br return a/b;.br }.fi.PPIf \fCb\fR is zero, the ASSERT statement will output the following message using the warning() function:.PP.nf.br ASSERT: "b == 0" in div.cpp (9).fi.PPSee also: warning() and Debugging.SH "Q_EXPORT bool qSysInfo (int * wordSize, bool * bigEndian)"Obtains information about the system..PPThe system's word size in bits (typically 32) is returned in \fI*wordSize.\fR The \fI*bigEndian\fR is set to TRUE if this is a big-endian machine, or to FALSE if this is a little-endian machine..PPThis function calls fatal() with a message if the computer is truly weird (i.e. different endianness for 16 bit and 32 bit integers)..SH "Q_EXPORT msg_handler qInstallMsgHandler (msg_handler h)"Installs a Qt message handler. Returns a pointer to the message handler previously defined..PPThe message handler is a function that prints out debug messages, warnings and fatal error messages. The Qt library (debug version) contains hundreds of warning messages that are printed when internal errors (usually invalid function arguments) occur. If you implement your own message handler, you get total control of these messages..PPThe default message handler prints the message to the standard output under X11 or to the debugger under Windows. If it is a fatal message, the application aborts immediately..PPOnly one message handler can be defined, since this is usually done on an application-wide basis to control debug output..PPTo restore the message handler, call \fCqInstallMsgHandler(0).\fR.PPExample:.PP.nf.br #include <qapplication.h>.br #include <stdio.h>.br #include <stdlib.h>.br.br void myMessageOutput( QtMsgType type, const char *msg ).br {.br switch ( type ) {.br case QtDebugMsg:.br fprintf( stderr, "Debug: %s\\n", msg );.br break;.br case QtWarningMsg:.br fprintf( stderr, "Warning: %s\\n", msg );.br break;.br case QtFatalMsg:.br fprintf( stderr, "Fatal: %s\\n", msg );.br abort(); // dump core on purpose.br }.br }.br.br int main( int argc, char **argv ).br {.br qInstallMsgHandler( myMessageOutput );.br QApplication a( argc, argv );.br ....br return a.exec();.br }.fi.PPSee also: debug(), warning(), fatal() and Debugging.SH "Q_EXPORT void qFatal (const char * msg, ...)"Prints a fatal error message and exits, or calls the message handler (if it has been installed)..PPThis function takes a format string and a list of arguments, similar to the C printf() function..PPExample:.PP.nf.br int divide( int a, int b ).br {.br if ( b == 0 ) // program error.br qFatal( "divide: cannot divide by zero" );.br return a/b;.br }.fi.PPUnder X11, the text is printed to stderr. Under Windows, the text is sent to the debugger..PP\fBWarning:\fR The internal buffer is limited to 512 bytes (including the 0-terminator)..PPSee also: debug(), warning(), qInstallMsgHandler() and Debugging.SH "Q_EXPORT const char * qVersion ()"Returns the Qt version number for the library, typically "1.30" or "1.31"..SH "Q_EXPORT void qDebug (const char * msg, ...)"Prints a debug message, or calls the message handler (if it has been installed)..PPThis function takes a format string and a list of arguments, similar to the C printf() function..PPExample:.PP.nf.br qDebug( "my window handle = %x", myWidget->id() );.fi.PPUnder X11, the text is printed to stderr. Under Windows, the text is sent to the debugger..PPNote: If DEBUG was not defined when the Qt library was built (i.e. NO_DEBUG was defined), this function does nothing..PP\fBWarning:\fR The internal buffer is limited to 512 bytes (including the 0-terminator)..PPSee also: warning(), fatal(), qInstallMsgHandler() and Debugging.PPExamples:.(lqdir/qdir.cpp mainlyXt/editor.cpp.)l.SH "void qAddPostRoutine (Q_CleanUpFunction p)"Adds a global routine that will be called from the QApplication destructor. This function is normally used to add cleanup routines..PPThe function given by \fIp\fR should take no arguments and return nothing..PPExample of use:.PP.nf.br static int *global_ptr = 0;.br.br void cleanup_ptr().br {.br delete [] global_ptr;.br }.br.br void init_ptr().br {.br global_ptr = new int[100]; // allocate data.br qAddPostRoutine( cleanup_ptr ); // delete later.br }.fi.SH "SEE ALSO".BR http://www.troll.no/qt/qapplication.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS. See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -