返回介绍

QSqlEditorFactory Class

发布于 2019-10-04 15:02:53 字数 2931 浏览 954 评论 0 收藏 0

The QSqlEditorFactory class is used to create the editors used by QDataTable and QSqlForm. More...

#include <qsqleditorfactory.h>

Inherits QEditorFactory.

List of all member functions.

Public Members

  • QSqlEditorFactory ( QObject*parent = 0, constchar*name = 0 )
  • ~QSqlEditorFactory ()
  • virtual QWidget * createEditor ( QWidget*parent, constQVariant&variant )
  • virtual QWidget * createEditor ( QWidget*parent, constQSqlField*field )

Static Public Members

  • QSqlEditorFactory * defaultFactory ()
  • void installDefaultFactory ( QSqlEditorFactory*factory )

Detailed Description

The QSqlEditorFactory class is used to create the editors used by QDataTable and QSqlForm.

QSqlEditorFactory is used by QDataTable and QSqlForm to automatically create appropriate editors for a given QSqlField. For example if the field is a QVariant::String a QLineEdit would be the default editor, whereas a QVariant::Int's default editor would be a QSpinBox.

If you want to create different editors for fields with the same data type, subclass QSqlEditorFactory and reimplement the createEditor() function.

See also QDataTable, QSqlForm and Database Classes.


Member Function Documentation

QSqlEditorFactory::QSqlEditorFactory ( QObject*parent = 0, constchar*name = 0 )

Constructs a SQL editor factory with parent parent and name name.

QSqlEditorFactory::~QSqlEditorFactory ()

Destroys the object and frees any allocated resources.

QWidget* QSqlEditorFactory::createEditor ( QWidget*parent, constQVariant&variant ) [virtual]

Creates and returns the appropriate editor widget for the QVariant variant.

The widget that is returned has the parent parent (which may be zero). If variant is invalid, 0 is returned.

Reimplemented from QEditorFactory.

QWidget* QSqlEditorFactory::createEditor ( QWidget*parent, constQSqlField*field ) [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Creates and returns the appropriate editor for the QSqlField field.

QSqlEditorFactory* QSqlEditorFactory::defaultFactory () [static]

Returns an instance of a default editor factory.

void QSqlEditorFactory::installDefaultFactory ( QSqlEditorFactory*factory ) [static]

Replaces the default editor factory with factory. All QDataTable and QSqlForm instantiations will use this new factory for creating field editors. QSqlEditorFactory takes ownership of factory, and destroys it when it is no longer needed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文