QSqlField(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

πŸ’– QSqlField β€” the manual page, bestie edition πŸ’–

okay so you found the qsqlfield.3qt man page and you're like "what is this" β€” don't worry, I got you. It's the Qt 3 docs, it's giving 2007, and it's genuinely useful. Let's go. ✨


🌸 NAME 🌸

QSqlField β€” Manipulates the fields in SQL database tables and views


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <qsqlfield.h>

✨ Public Members ✨

QSqlField ( const QString & fieldName = QString::null, QVariant::Type
    type = QVariant::Invalid )
QSqlField ( const QSqlField & other )
QSqlField & operator= ( const QSqlField & other )
bool operator== ( const QSqlField & other ) const
virtual ~QSqlField ()
virtual void setValue ( const QVariant & value )
virtual QVariant value () const
virtual void setName ( const QString & name )
QString name () const
virtual void setNull ()
bool isNull () const
virtual void setReadOnly ( bool readOnly )
bool isReadOnly () const
void clear ( bool nullify = TRUE )
QVariant::Type type () const

🌈 DESCRIPTION 🌈

The QSqlField class manipulates the fields in SQL database tables and views. periodt.

QSqlField represents the characteristics of a single column in a database table or view β€” like the data type and the column name. And bestie, a field also holds the actual value of that database column, which you can look at or change. main character energy honestly. πŸ‘‘

Field data values are stored as QVariants. Using an incompatible type is not permitted. For example:

QSqlField f( "myfield", QVariant::Int );
f.setValue( QPixmap() );  // will not work

However (and this is the slay part πŸ’…), the field will attempt to cast certain data types to the field's data type where possible:

QSqlField f( "myfield", QVariant::Int );
f.setValue( QString("123") ); // casts QString to int

QSqlField objects are rarely created explicitly in application code. Like, almost never. They're usually accessed indirectly through QSqlRecord or QSqlCursor, which already contain a list of fields. For example:

QSqlCursor cur( "Employee" );        // create cursor using the 'Employee' table
QSqlField* f = cur.field( "name" );  // use the 'name' field
f->setValue( "Dave" );               // set field value
...

In practice we rarely need to extract a pointer to a field at all. The previous example would normally be written:

QSqlCursor cur( "Employee" );
cur.setValue( "name", "Dave" );
...

See also Database Classes.


πŸŽ€ MEMBER FUNCTION DOCUMENTATION πŸŽ€

⭐ QSqlField::QSqlField ( const QString & fieldName = QString::null, QVariant::Type type = QVariant::Invalid )

Constructs an empty field called fieldName of type type. brand new, blank canvas, iconic.

⭐ QSqlField::QSqlField ( const QSqlField & other )

Constructs a copy of other. twin behavior fr fr 🫢

⭐ QSqlField::~QSqlField () [virtual]

Destroys the object and frees any allocated resources. bye bestie 😭

⭐ void QSqlField::clear ( bool nullify = TRUE )

Clears the value of the field. If the field is read-only, nothing happens. If nullify is TRUE (the default), the field is set to NULL.

⭐ bool QSqlField::isNull () const

Returns TRUE if the field is currently NULL; otherwise returns FALSE.

⭐ bool QSqlField::isReadOnly () const

Returns TRUE if the field's value is read only; otherwise returns FALSE.

⭐ QString QSqlField::name () const

Returns the name of the field.

Example: sql/overview/table4/main.cpp.

⭐ QSqlField & QSqlField::operator= ( const QSqlField & other )

Sets the field equal to other.

⭐ bool QSqlField::operator== ( const QSqlField & other ) const

Returns TRUE if the field is equal to other; otherwise returns FALSE. Fields are considered equal when the following field properties are the same:

  • name()
  • isNull()
  • value()
  • isReadOnly()
not me checking four whole things before calling two fields equal πŸ’€ but okay, it's thorough and we respect it.

⭐ void QSqlField::setName ( const QString & name ) [virtual]

Sets the name of the field to name.

⭐ void QSqlField::setNull () [virtual]

Sets the field to NULL and clears the value using clear(). If the field is read-only, nothing happens.

See also isReadOnly() and clear().

⭐ void QSqlField::setReadOnly ( bool readOnly ) [virtual]

Sets the read only flag of the field's value to readOnly.

See also setValue().

⭐ void QSqlField::setValue ( const QVariant & value ) [virtual]

Sets the value of the field to value. If the field is read-only (isReadOnly() returns TRUE), nothing happens. If the data type of value differs from the field's current data type, an attempt is made to cast it to the proper type. This preserves the data type of the field in the case of assignment, e.g. a QString to an integer data type. For example:

QSqlCursor cur( "Employee" );                 // 'Employee' table
QSqlField* f = cur.field( "student_count" );  // an integer field
...
f->setValue( myLineEdit->text() );            // cast the line edit text to an integer

See also isReadOnly().

⭐ QVariant::Type QSqlField::type () const

Returns the field's type as stored in the database. Note that the actual value might have a different type. Numerical values that are too large to store in a long int or double are usually stored as strings to prevent precision loss. πŸ’€ classic.

⭐ QVariant QSqlField::value () const [virtual]

Returns the value of the field as a QVariant.

Example: sql/overview/table4/main.cpp.


πŸ”₯ SEE ALSO πŸ”₯


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.


🧚 AUTHOR 🧚

Generated automatically from the source code. (yes, a robot wrote this and we're still thanking it, iconic)


πŸ’€ BUGS πŸ’€

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you.

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qsqlfield.3qt) and the Qt version (3.3.8).

fr fr include the version, they will absolutely need it πŸ’…

and that's the whole page, bestie!! πŸŽ€ this gem came to you from Trolltech AS, dated 2 February 2007, and its man page name is QSqlField(3qt) β€” Qt 3 era, still serving looks. go forth and set some field values. mwah πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from