Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsqlfield.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSQLFIELD_H
5#define QSQLFIELD_H
6
7#include <QtSql/qtsqlglobal.h>
8#include <QtCore/qshareddata.h>
9#include <QtCore/qvariant.h>
10#include <QtCore/qstring.h>
11
13
14
17
18class Q_SQL_EXPORT QSqlField
19{
21public:
22 enum RequiredStatus { Unknown = -1, Optional = 0, Required = 1 };
23
25 Q_PROPERTY(QVariant defaultValue READ defaultValue WRITE setDefaultValue)
27 Q_PROPERTY(QString tableName READ tableName WRITE setTableName)
28 Q_PROPERTY(QMetaType metaType READ metaType WRITE setMetaType)
29 Q_PROPERTY(RequiredStatus requiredStatus READ requiredStatus WRITE setRequiredStatus)
30 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
31 Q_PROPERTY(bool generated READ isGenerated WRITE setGenerated)
32 Q_PROPERTY(bool autoValue READ isAutoValue WRITE setAutoValue)
33 Q_PROPERTY(int length READ length WRITE setLength)
34 Q_PROPERTY(int precision READ precision WRITE setPrecision)
35
36 explicit QSqlField(const QString& fieldName = QString(), QMetaType type = QMetaType(), const QString &tableName = QString());
37
39 QSqlField& operator=(const QSqlField& other);
40 QSqlField(QSqlField &&other) noexcept = default;
41 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QSqlField)
43
44 void swap(QSqlField &other) noexcept { val.swap(other.val); d.swap(other.d); }
45
46 bool operator==(const QSqlField& other) const;
47 inline bool operator!=(const QSqlField &other) const { return !operator==(other); }
48
49 void setValue(const QVariant& value);
50 inline QVariant value() const
51 { return val; }
52 void setName(const QString& name);
53 QString name() const;
54 void setTableName(const QString &tableName);
55 QString tableName() const;
56 bool isNull() const;
57 void setReadOnly(bool readOnly);
58 bool isReadOnly() const;
59 void clear();
60 bool isAutoValue() const;
61
62 QMetaType metaType() const;
63 void setMetaType(QMetaType type);
64
65#if QT_DEPRECATED_SINCE(6, 0)
68 QT_DEPRECATED_VERSION_X_6_0("Use the constructor using a QMetaType instead")
69 QSqlField(const QString& fieldName, QVariant::Type type, const QString &tableName = QString())
70 : QSqlField(fieldName, QMetaType(type), tableName)
71 {}
72 QT_DEPRECATED_VERSION_X_6_0("Use metaType() instead")
73 QVariant::Type type() const { return QVariant::Type(metaType().id()); };
74 QT_DEPRECATED_VERSION_X_6_0("Use setMetaType() instead")
75 void setType(QVariant::Type type) { setMetaType(QMetaType(int(type))); }
77#endif
78
79 void setRequiredStatus(RequiredStatus status);
80 inline void setRequired(bool required)
81 { setRequiredStatus(required ? Required : Optional); }
82 void setLength(int fieldLength);
83 void setPrecision(int precision);
84 void setDefaultValue(const QVariant &value);
85 void setGenerated(bool gen);
86 void setAutoValue(bool autoVal);
87
88 RequiredStatus requiredStatus() const;
89 int length() const;
90 int precision() const;
91 QVariant defaultValue() const;
92 bool isGenerated() const;
93 bool isValid() const;
94
95#if QT_DEPRECATED_SINCE(6, 8)
96 QT_DEPRECATED_VERSION_X_6_8("This internal value is no longer used.")
97 void setSqlType(int type);
98 QT_DEPRECATED_VERSION_X_6_8("This internal value is no longer used.")
99 int typeID() const;
100#endif
101private:
102 void detach();
103 // ### Qt7: move to private class
105 QExplicitlySharedDataPointer<QSqlFieldPrivate> d;
106};
107
108Q_DECLARE_SHARED(QSqlField)
109
110#ifndef QT_NO_DEBUG_STREAM
111Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlField &);
112#endif
113
115
116#endif // QSQLFIELD_H
\inmodule QtCore
\inmodule QtCore
Definition qmetatype.h:341
The QSqlField class manipulates the fields in SQL database tables and views.
Definition qsqlfield.h:19
RequiredStatus
Specifies whether the field is required or optional.
Definition qsqlfield.h:22
bool operator!=(const QSqlField &other) const
Returns true if the field is unequal to other; otherwise returns false.
Definition qsqlfield.h:47
void setRequired(bool required)
Sets the required status of this field to \l Required if required is true; otherwise sets it to \l Op...
Definition qsqlfield.h:80
QVariant value() const
Returns the value of \l value.
Definition qsqlfield.h:50
void swap(QSqlField &other) noexcept
Definition qsqlfield.h:44
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
b clear()
employee setName("Richard Schmit")
Combined button and popup list for selecting options.
#define QT_WARNING_POP
#define QT_WARNING_DISABLE_DEPRECATED
#define QT_WARNING_PUSH
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
@ Required
GLenum GLuint GLenum GLsizei length
GLenum type
GLuint name
GLuint GLfloat * val
GLenum GLint GLint * precision
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(Class, ExportMacro)
static bool isAutoValue(const SQLHANDLE hStmt, int column)
Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlField &)
#define QT_DEPRECATED_VERSION_X_6_0(text)
#define QT_DEPRECATED_VERSION_X_6_8(text)
#define Q_PROPERTY(...)
#define Q_GADGET
#define explicit
settings setValue("DataPump/bgcolor", color)
QSharedPointer< T > other(t)
[5]
this swap(other)
proxy setType(QNetworkProxy::Socks5Proxy)
Definition moc.h:23