📄 qvariant.3qt
字号:
.PPSee also toString()..SH "QPen & QVariant::asPen ()"Tries to convert the variant to hold a QPen value. If that is not possible then the variant is set to an empty pen..PPReturns a reference to the stored pen..PPSee also toPen()..SH "QPixmap & QVariant::asPixmap ()"Tries to convert the variant to hold a pixmap value. If that is not possible the variant is set to a null pixmap..PPReturns a reference to the stored pixmap..PPSee also toPixmap()..SH "QPoint & QVariant::asPoint ()"Tries to convert the variant to hold a point value. If that is not possible the variant is set to a (0, 0) point..PPReturns a reference to the stored point..PPSee also toPoint()..SH "QPointArray & QVariant::asPointArray ()"Tries to convert the variant to hold a QPointArray value. If that is not possible the variant is set to an empty point array..PPReturns a reference to the stored point array..PPSee also toPointArray()..SH "QRect & QVariant::asRect ()"Tries to convert the variant to hold a rectangle value. If that is not possible the variant is set to an empty rectangle..PPReturns a reference to the stored rectangle..PPSee also toRect()..SH "QRegion & QVariant::asRegion ()"Tries to convert the variant to hold a QRegion value. If that is not possible the variant is set to a null region..PPReturns a reference to the stored region..PPSee also toRegion()..SH "QSize & QVariant::asSize ()"Tries to convert the variant to hold a QSize value. If that is not possible the variant is set to an invalid size..PPReturns a reference to the stored size..PPSee also toSize() and QSize::isValid()..SH "QSizePolicy & QVariant::asSizePolicy ()"Tries to convert the variant to hold a QSizePolicy value. If that fails, the variant is set to an arbitrary (valid) size policy..SH "QString & QVariant::asString ()"Tries to convert the variant to hold a string value. If that is not possible the variant is set to an empty string..PPReturns a reference to the stored string..PPSee also toString()..SH "QStringList & QVariant::asStringList ()"Tries to convert the variant to hold a QStringList value. If that is not possible the variant is set to an empty string list..PPReturns a reference to the stored string list..PPNote that if you want to iterate over the list, you should iterate over a copy, e.g..PP.nf.br QStringList list = myVariant.asStringList();.br QStringList::Iterator it = list.begin();.br while( it != list.end() ) {.br myProcessing( *it );.br ++it;.br }.br.fi.PPSee also toStringList()..SH "QTime & QVariant::asTime ()"Tries to convert the variant to hold a QTime value. If that is not possible then the variant is set to an invalid time..PPReturns a reference to the stored time..PPSee also toTime()..SH "uint & QVariant::asUInt ()"Returns the variant's value as unsigned int reference..SH "Q_ULLONG & QVariant::asULongLong ()"Returns the variant's value as unsigned long long reference..SH "bool QVariant::canCast ( Type t ) const"Returns TRUE if the variant's type can be cast to the requested type, \fIt\fR. Such casting is done automatically when calling the toInt(), toBool(), ... or asInt(), asBool(), ... methods..PPThe following casts are done automatically: <center>.nf.TSl - l. Type Automatically Cast To Bool Double, Int, UInt, LongLong, ULongLong Color String Date String, DateTime DateTime String, Date, Time Double String, Int, Bool, UInt Font String Int String, Double, Bool, UInt List StringList (if the list contains strings or something that can be cast to a string) String CString, Int, Uint, Bool, Double, Date, Time, DateTime, KeySequence, Font, Color CString String StringList List Time String UInt String, Double, Bool, Int KeySequence.TE.fi</center>.SH "bool QVariant::cast ( Type t )"Casts the variant to the requested type. If the cast cannot be done, the variant is set to the default value of the requested type (e.g. an empty string if the requested type \fIt\fR is QVariant::String, an empty point array if the requested type \fIt\fR is QVariant::PointArray, etc). Returns TRUE if the current type of the variant was successfully cast; otherwise returns FALSE..PPSee also canCast()..SH "void QVariant::clear ()"Convert this variant to type Invalid and free up any resources used..SH "bool QVariant::isNull () const"Returns TRUE if this is a NULL variant, FALSE otherwise..SH "bool QVariant::isValid () const"Returns TRUE if the storage type of this variant is not QVariant::Invalid; otherwise returns FALSE..SH "QValueListConstIterator<QVariant> QVariant::listBegin () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns an iterator to the first item in the list if the variant's type is appropriate; otherwise returns a null iterator..SH "QValueListConstIterator<QVariant> QVariant::listEnd () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns the end iterator for the list if the variant's type is appropriate; otherwise returns a null iterator..SH "QMapConstIterator<QString, QVariant> QVariant::mapBegin () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns an iterator to the first item in the map, if the variant's type is appropriate; otherwise returns a null iterator..SH "QMapConstIterator<QString, QVariant> QVariant::mapEnd () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns the end iterator for the map, if the variant's type is appropriate; otherwise returns a null iterator..SH "QMapConstIterator<QString, QVariant> QVariant::mapFind ( const QString & key ) const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns an iterator to the item in the map with \fIkey\fR as key, if the variant's type is appropriate and \fIkey\fR is a valid key; otherwise returns a null iterator..SH "Type QVariant::nameToType ( const char * name )\fC [static]\fR"Converts the string representation of the storage type gven in \fIname\fR, to its enum representation..PPIf the string representation cannot be converted to any enum representation, the variant is set to Invalid..SH "bool QVariant::operator!= ( const QVariant & v ) const"Compares this QVariant with \fIv\fR and returns TRUE if they are not equal; otherwise returns FALSE..SH "QVariant & QVariant::operator= ( const QVariant & variant )"Assigns the value of the variant \fIvariant\fR to this variant..PPThis is a deep copy of the variant, but note that if the variant holds an explicitly shared type such as QImage, a shallow copy is performed..SH "bool QVariant::operator== ( const QVariant & v ) const"Compares this QVariant with \fIv\fR and returns TRUE if they are equal; otherwise returns FALSE..SH "QValueListConstIterator<QString> QVariant::stringListBegin () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns an iterator to the first string in the list if the variant's type is StringList; otherwise returns a null iterator..SH "QValueListConstIterator<QString> QVariant::stringListEnd () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns the end iterator for the list if the variant's type is StringList; otherwise returns a null iterator..SH "const QBitArray QVariant::toBitArray () const"Returns the variant as a QBitArray if the variant has type() BitArray; otherwise returns an empty bitarray..PPSee also asBitArray()..SH "const QBitmap QVariant::toBitmap () const"Returns the variant as a QBitmap if the variant has type() Bitmap; otherwise returns a null QBitmap..PPSee also asBitmap()..SH "bool QVariant::toBool () const"Returns the variant as a bool if the variant has type() Bool..PPReturns TRUE if the variant has type Int, UInt or Double and its value is non-zero, or if the variant has type String and its lower-case content is not empty, "0" or "false"; otherwise returns FALSE..PPSee also asBool()..SH "const QBrush QVariant::toBrush () const"Returns the variant as a QBrush if the variant has type() Brush; otherwise returns a default brush (with all black colors)..PPSee also asBrush()..SH "const QByteArray QVariant::toByteArray () const"Returns the variant as a QByteArray if the variant has type() ByteArray or CString; otherwise returns an empty bytearray..PPSee also asByteArray()..SH "const QCString QVariant::toCString () const"Returns the variant as a QCString if the variant has type() CString or String; otherwise returns 0..PPSee also asCString()..SH "const QColor QVariant::toColor () const"Returns the variant as a QColor if the variant has type() Color; otherwise returns an invalid color..PPSee also asColor()..SH "const QColorGroup QVariant::toColorGroup () const"Returns the variant as a QColorGroup if the variant has type() ColorGroup; otherwise returns a completely black color group..PPSee also asColorGroup()..SH "const QCursor QVariant::toCursor () const"Returns the variant as a QCursor if the variant has type() Cursor; otherwise returns the default arrow cursor..PPSee also asCursor()..SH "const QDate QVariant::toDate () const"Returns the variant as a QDate if the variant has type() Date, DateTime or String; otherwise returns an invalid date..PPNote that if the type() is String an invalid date will be returned if the string cannot be parsed as a Qt::ISODate format date..PPSee also asDate()..SH "const QDateTime QVariant::toDateTime () const"Returns the variant as a QDateTime if the variant has type() DateTime, Date or String; otherwise returns an invalid date/time..PPNote that if the type() is String an invalid date/time will be returned if the string cannot be parsed as a Qt::ISODate format date/time..PPSee also asDateTime()..SH "double QVariant::toDouble ( bool * ok = 0 ) const"Returns the variant as a double if the variant has type() String, CString, Double, Int, UInt, LongLong, ULongLong or Bool; otherwise returns 0.0..PPIf \fIok\fR is non-null: \fI*ok\fR is set to TRUE if the value could be converted to a double; otherwise \fI*ok\fR is set to FALSE..PPSee also asDouble()..SH "const QFont QVariant::toFont () const"Returns the variant as a QFont if the variant has type() Font; otherwise returns the application's default font..PPSee also asFont()..SH "const QIconSet QVariant::toIconSet () const"Returns the variant as a QIconSet if the variant has type() IconSet; otherwise returns an icon set of null pixmaps..PPSee also asIconSet()..SH "const QImage QVariant::toImage () const"Returns the variant as a QImage if the variant has type() Image; otherwise returns a null image..PPSee also asImage()..SH "int QVariant::toInt ( bool * ok = 0 ) const"Returns the variant as an int if the variant has type() String, CString, Int, UInt, Double, Bool or KeySequence; otherwise returns 0..PPIf \fIok\fR is non-null: \fI*ok\fR is set to TRUE if the value could be converted to an int; otherwise \fI*ok\fR is set to FALSE..PPSee also asInt() and canCast()..SH "const QKeySequence QVariant::toKeySequence () const"Returns the variant as a QKeySequence if the variant has type() KeySequence, Int or String; otherwise returns an empty key sequence..PPNote that not all Ints and Strings are valid key sequences and in such cases an empty key sequence will be returned..PPSee also asKeySequence()..SH "const QValueList<QVariant> QVariant::toList () const"Returns the variant as a QValueList<QVariant> if the variant has type() List or StringList; otherwise returns an empty list..PPNote that if you want to iterate over the list, you should iterate over a copy, e.g..PP.nf.br QValueList<QVariant> list = myVariant.toList();.br QValueList<QVariant>::Iterator it = list.begin();.br while( it != list.end() ) {.br myProcessing( *it );.br ++it;.br }.br.fi.PPSee also asList()..SH "Q_LLONG QVariant::toLongLong ( bool * ok = 0 ) const"Returns the variant as a long long int if the variant has type() LongLong, ULongLong, any type allowing a toInt() conversion; otherwise returns 0..PPIf \fIok\fR is non-null: \fI*ok\fR is set to TRUE if the value could be converted to an int; otherwise \fI*ok\fR is set to FALSE..PPSee also asLongLong() and canCast()..SH "const QMap<QString, QVariant> QVariant::toMap () const"Returns the variant as a QMap<QString,QVariant> if the variant has type() Map; otherwise returns an empty map..PPNote that if you want to iterate over the map, you should iterate over a copy, e.g..PP.nf.br QMap<QString, QVariant> map = myVariant.toMap();.br QMap<QString, QVariant>::Iterator it = map.begin();.br while( it != map.end() ) {.br myProcessing( *it );.br ++it;.br }.br.fi.PPSee also asMap()..SH "const QPalette QVariant::toPalette () const"Returns the variant as a QPalette if the variant has type() Palette; otherwise returns a completely black palette..PPSee also asPalette()..SH "const QPen QVariant::toPen () const"Returns the variant as a QPen if the variant has type() Pen; otherwise returns an empty QPen..PPSee also asPen()..SH "const QPixmap QVariant::toPixmap () const"Returns the variant as a QPixmap if the variant has type() Pixmap; otherwise returns a null pixmap..PPSee also asPixmap()..SH "const QPoint QVariant::toPoint () const"Returns the variant as a QPoint if the variant has type() Point; otherwise returns a point (0, 0)..PPSee also asPoint()..SH "const QPointArray QVariant::toPointArray () const"Returns the variant as a QPointArray if the variant has type() PointArray; otherwise returns an empty QPointArray..PPSee also asPointArray()..SH "const QRect QVariant::toRect () const"Returns the variant as a QRect if the variant has type() Rect; otherwise returns an empty rectangle..PPSee also asRect()..SH "const QRegion QVariant::toRegion () const"Returns the variant as a QRegion if the variant has type() Region; otherwise returns an empty QRegion..PPSee also asRegion()..SH "const QSize QVariant::toSize () const"Returns the variant as a QSize if the variant has type() Size; otherwise returns an invalid size..PPSee also asSize()..SH "QSizePolicy QVariant::toSizePolicy () const"Returns the variant as a QSizePolicy if the variant has type() SizePolicy; otherwise returns an undefined (but legal) size policy..SH "const QString QVariant::toString () const"Returns the variant as a QString if the variant has type() String, CString, ByteArray, Int, Uint, Bool, Double, Date, Time, DateTime, KeySequence, Font or Color; otherwise returns QString::null..PPSee also asString()..SH "const QStringList QVariant::toStringList () const"Returns the variant as a QStringList if the variant has type() StringList or List of a type that can be converted to QString; otherwise returns an empty list..PPNote that if you want to iterate over the list, you should iterate over a copy, e.g..PP.nf.br QStringList list = myVariant.toStringList();.br QStringList::Iterator it = list.begin();.br while( it != list.end() ) {.br myProcessing( *it );.br ++it;.br }.br.fi.PPSee also asStringList()..SH "const QTime QVariant::toTime () const"Returns the variant as a QTime if the variant has type() Time, DateTime or String; otherwise returns an invalid time..PPNote that if the type() is String an invalid time will be returned if the string cannot be parsed as a Qt::ISODate format time..PPSee also asTime()..SH "uint QVariant::toUInt ( bool * ok = 0 ) const"Returns the variant as an unsigned int if the variant has type() String, CString, UInt, Int, Double, or Bool; otherwise returns 0..PPIf \fIok\fR is non-null: \fI*ok\fR is set to TRUE if the value could be converted to an unsigned int; otherwise \fI*ok\fR is set to FALSE..PPSee also asUInt()..SH "Q_ULLONG QVariant::toULongLong ( bool * ok = 0 ) const"Returns the variant as as an unsigned long long int if the variant has type() LongLong, ULongLong, any type allowing a toUInt() conversion; otherwise returns 0..PPIf \fIok\fR is non-null: \fI*ok\fR is set to TRUE if the value could be converted to an int; otherwise \fI*ok\fR is set to FALSE..PPSee also asULongLong() and canCast()..SH "Type QVariant::type () const"Returns the storage type of the value stored in the variant. Usually it's best to test with canCast() whether the variant can deliver the data type you are interested in..SH "const char * QVariant::typeName () const"Returns the name of the type stored in the variant. The returned strings describe the C++ datatype used to store the data: for example, "QFont", "QString", or "QValueList<QVariant>". An Invalid variant returns 0..SH "const char * QVariant::typeToName ( Type typ )\fC [static]\fR"Converts the enum representation of the storage type, \fItyp\fR, toits string representation..SH "SEE ALSO".BR http://doc.trolltech.com/qvariant.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 (qvariant.3qt) and the Qtversion (3.2.3).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -