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

📄 qapplication.3qt

📁 Trolltech公司发布的基于C++图形开发环境
💻 3QT
📖 第 1 页 / 共 5 页
字号:
.br    // Shows all hidden top level widgets..br    //.br    QWidgetList  *list = QApplication::topLevelWidgets();.br    QWidgetListIt it( *list );  // iterate over the widgets.br    QWidget * w;.br    while ( (w=it.current()) != 0 ) {   // for each top level widget....br        ++it;.br        if ( !w->isVisible() ).br            w->show();.br    }.br    delete list;                // delete the list, not the widgets.fi.PP\fBWarning:\fR Delete the list away as soon you have finished using it. The widgets in the list may be deleted by someone else at any time..PPSee also allWidgets(), QWidget::isTopLevel(), QWidget::isVisible() and QList::isEmpty()..SH "QString QApplication::translate ( const char * scope, const char * key, const char * comment ) const"Returns the translation text for \fIkey,\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\fIcontext\fR is typically a class name (e.g. \fCMyDialog)\fR and \fIkey\fR is either English text or a short marker text, if the output text will be very long (as for help texts)..PP\fIcomment\fR is a disambiguating comment, for when the same text is used in different roles within one context..PPSee the QTranslator documentation for more information about keys, contexts and comments..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 "QString QApplication::translate ( const char * context, const char * key ) const"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPThis is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..PPThis version of the function uses "" as comment..SH "void QApplication::unlock ( bool wakeUpGui = TRUE )"Unlock the Qt library mutex. if \fIwakeUpGui\fR is TRUE (default argument), then the GUI thread will be woken with QApplication::wakeUpGuiThread()..PPSee also lock() and locked()..SH "void QApplication::wakeUpGuiThread ()"Wakes up the GUI thread..PPSee also guiThreadAwake()..SH "int QApplication::wheelScrollLines () \fC[static]\fR"Returns the number of lines to scroll when the mouse wheel is rotated..PPSee also setWheelScrollLines()..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..PPThis function is normally rather slow..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 source working, and will probably be removed in a future version of Qt. 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 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 8196 bytes (including the 0-terminator)..PPSee also qDebug(), qWarning(), qInstallMsgHandler() and Debugging.SH "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 8196 bytes (including the 0-terminator)..PPSee also qDebug(), qFatal(), qInstallMsgHandler() and Debugging.PPExamples:.(llife/main.cpp progress/progress.cpp tictac/main.cpp.)l.SH "const char * qVersion ()"Returns the Qt version number for the library, typically "1.30" or "2.1.0"..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 for program-wide functionality..PPThe function given by \fIp\fR should take no arguments and return nothing, like this:.PP.nf.br    static int *global_ptr = 0;.br.br    static void cleanup_ptr().br    {.br        delete [] global_ptr;.br        global_ptr = 0;.br    }.br.br    void init_ptr().br    {.br        global_ptr = new int[100];      // allocate data.br        qAddPostRoutine( cleanup_ptr ); // delete later.br    }.fi.PPNote that for an application- or module-wide cleanup, qAddPostRoutine() is often not suitable. People have a tendency to make such modules dynamically loaded, and then unload those modules long before the QApplication destructor is called, for example..PPFor modules and libraries, using a reference-counted initialization manager or Qt' parent-child delete mechanism may be better. Here is an example of a private class which uses the parent-child mechanism to call a cleanup function at the right time:.PP.nf.br    class MyPrivateInitStuff: public QObject {.br    private:.br        MyPrivateInitStuff( QObject * parent ): QObject( parent) {.br            // initialization goes here.br        }.br        MyPrivateInitStuff * p;.br.br    public:.br        static MyPrivateInitStuff * initStuff( QObject * parent ) {.br            if ( !p ).br                p = new MyPrivateInitStuff( parent );.br            return p;.br        }.br.br        ~MyPrivateInitStuff() {.br            // cleanup (the "post routine") goes here.br        }.br    }.fi.PPBy selecting the right parent widget/object, this can often be made to clean up the module's data at the exact right moment..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 qWarning() function:.PP.nf.br    ASSERT: "b == 0" in div.cpp (9).fi.PPSee also qWarning() and Debugging.SH "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..PP\fBWarning:\fR The internal buffer is limited to 8196 bytes (including the 0-terminator)..PPSee also qWarning(), qFatal(), qInstallMsgHandler() and Debugging.SH "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 qFatal() with a message if the computer is truly weird (i.e. different endianness for 16 bit and 32 bit integers)..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 qFatal() and Debugging.SH "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 cont

⌨️ 快捷键说明

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