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

📄 qguardedptr.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
字号:
'\" t.TH QGuardedPtr 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQGuardedPtr \- Template class that provides guarded pointers to QObjects.PP\fC#include <qguardedptr.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "\fBQGuardedPtr\fR ()".br.ti -1c.BI "\fBQGuardedPtr\fR ( T * p )".br.ti -1c.BI "\fBQGuardedPtr\fR ( const QGuardedPtr<T> & p )".br.ti -1c.BI "\fB~QGuardedPtr\fR ()".br.ti -1c.BI "QGuardedPtr<T> & \fBoperator=\fR ( const QGuardedPtr<T> & p )".br.ti -1c.BI "QGuardedPtr<T> & \fBoperator=\fR ( T * p )".br.ti -1c.BI "bool \fBoperator==\fR ( const QGuardedPtr<T> & p ) const".br.ti -1c.BI "bool \fBoperator!=\fR ( const QGuardedPtr<T> & p ) const".br.ti -1c.BI "bool \fBisNull\fR () const".br.ti -1c.BI "T * \fBoperator->\fR () const".br.ti -1c.BI "T & \fBoperator*\fR () const".br.ti -1c.BI "\fBoperator T *\fR () const".br.in -1c.SH DESCRIPTIONThe QGuardedPtr class is a template class that provides guarded pointers to QObjects..PPA guarded pointer, QGuardedPtr<\fIX\fR>, behaves like a normal C++ pointer \fIX*\fR, except that it is automatically set to null when the referenced object is destroyed (unlike normal C++ pointers, which become "dangling pointers" in such cases). \fIX\fR must be a subclass of QObject..PPGuarded pointers are useful whenever you need to store a pointer to a QObject that is owned by someone else and therefore might be destroyed while you still keep a reference to it. You can safely test the pointer for validity..PPExample:.PP.nf.br      QGuardedPtr<QFrame> label = new QLabel( 0,"label" );.br      label->setText("I like guarded pointers");.br.br      delete (QLabel*) label; // emulate somebody destroying the label.br.br      if ( label).br          label->show();.br      else.br          qDebug("The label has been destroyed");.br.fi.PPThe program will output.PP.nf.br      The label has been destroyed.br.firather than dereferencing an invalid address in \fClabel->show()\fR..PPThe functions and operators available with a QGuardedPtr are the same as those available with a normal unguarded pointer, except the pointer arithmetic operators (++, --, -, and +), which are normally used only with arrays of objects. Use them like normal pointers and you will not need to read this class documentation..PPFor creating guarded pointers, you can construct or assign to them from an X* or from another guarded pointer of the same type. You can compare them with each other for equality (==) and inequality (!=), or test for null with isNull(). Finally, you can dereference them using either the \fC*x\fR or the \fCx->member\fR notation..PPA guarded pointer will automatically cast to an X*, so you can freely mix guarded and unguarded pointers. This means that if you have a QGuardedPtr<QWidget>, you can pass it to a function that requires a QWidget*. For this reason, it is of little value to declare functions to take a QGuardedPtr as a parameter - just use normal pointers. Use a QGuardedPtr when you are storing a pointer over time..PPNote again that class \fIX\fR must inherit QObject, or a compilation or link error will result..PPSee also Object Model..SH MEMBER FUNCTION DOCUMENTATION.SH "QGuardedPtr::QGuardedPtr ()"Constructs a null guarded pointer..PPSee also isNull()..SH "QGuardedPtr::QGuardedPtr ( T * p )"Constructs a guarded pointer that points to same object as \fIp\fR points to..SH "QGuardedPtr::QGuardedPtr ( const QGuardedPtr<T> & p )"Copy one guarded pointer from another. The constructed guarded pointer points to the same object that \fIp\fR points to (which may be null)..SH "QGuardedPtr::~QGuardedPtr ()"Destroys the guarded pointer. Just like a normal pointer, destroying a guarded pointer does \fInot\fR destroy the object being pointed to..SH "bool QGuardedPtr::isNull () const"Returns \fCTRUE\fR if the referenced object has been destroyed or if there is no referenced object..SH "QGuardedPtr::operator T * () const"Cast operator; implements pointer semantics. Because of this function you can pass a QGuardedPtr<X> to a function where an X* is required..SH "bool QGuardedPtr::operator!= ( const QGuardedPtr<T> & p ) const"Inequality operator; implements pointer semantics, the negation of operator==. Returns TRUE if \fIp\fR and this guarded pointer are not pointing to the same object; otherwise returns FALSE..SH "T & QGuardedPtr::operator* () const"Dereference operator; implements pointer semantics. Just use this operator as you would with a normal C++ pointer..SH "T * QGuardedPtr::operator-> () const"Overloaded arrow operator; implements pointer semantics. Just use this operator as you would with a normal C++ pointer..SH "QGuardedPtr<T> & QGuardedPtr::operator= ( const QGuardedPtr<T> & p )"Assignment operator. This guarded pointer then points to the same object as \fIp\fR points to..SH "QGuardedPtr<T> & QGuardedPtr::operator= ( T * p )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAssignment operator. This guarded pointer then points to same object as \fIp\fR points to..SH "bool QGuardedPtr::operator== ( const QGuardedPtr<T> & p ) const"Equality operator; implements traditional pointer semantics. Returns TRUE if both \fIp\fR and this guarded pointer are null, or if both \fIp\fR and this point to the same object; otherwise returns FALSE..PPSee also operator!=()..SH "SEE ALSO".BR http://doc.trolltech.com/qguardedptr.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qguardedptr.3qt) and the Qtversion (3.0.0).

⌨️ 快捷键说明

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