Qt 4.8
Public Functions | List of all members
QDefaultItemEditorFactory Class Reference
Inheritance diagram for QDefaultItemEditorFactory:
QItemEditorFactory

Public Functions

QWidgetcreateEditor (QVariant::Type type, QWidget *parent) const
 Creates an editor widget with the given parent for the specified type of data, and returns it as a QWidget. More...
 
 QDefaultItemEditorFactory ()
 
QByteArray valuePropertyName (QVariant::Type) const
 Returns the property name used to access data for the given type of data. More...
 
- Public Functions inherited from QItemEditorFactory
 QItemEditorFactory ()
 Constructs a new item editor factory. More...
 
void registerEditor (QVariant::Type type, QItemEditorCreatorBase *creator)
 Registers an item editor creator specified by creator for the given type of data. More...
 
virtual ~QItemEditorFactory ()
 Destroys the item editor factory. More...
 

Additional Inherited Members

- Static Public Functions inherited from QItemEditorFactory
static const QItemEditorFactorydefaultFactory ()
 Returns the default item editor factory. More...
 
static void setDefaultFactory (QItemEditorFactory *factory)
 Sets the default item editor factory to the given factory. More...
 

Detailed Description

Definition at line 195 of file qitemeditorfactory.cpp.

Constructors and Destructors

◆ QDefaultItemEditorFactory()

QDefaultItemEditorFactory::QDefaultItemEditorFactory ( )
inline

Definition at line 198 of file qitemeditorfactory.cpp.

198 {}

Functions

◆ createEditor()

QWidget * QDefaultItemEditorFactory::createEditor ( QVariant::Type  type,
QWidget parent 
) const
virtual

Creates an editor widget with the given parent for the specified type of data, and returns it as a QWidget.

See also
registerEditor()

Reimplemented from QItemEditorFactory.

Definition at line 203 of file qitemeditorfactory.cpp.

204 {
205  switch (type) {
206 #ifndef QT_NO_COMBOBOX
207  case QVariant::Bool: {
208  QBooleanComboBox *cb = new QBooleanComboBox(parent);
209  cb->setFrame(false);
210  return cb; }
211 #endif
212 #ifndef QT_NO_SPINBOX
213  case QVariant::UInt: {
214  QSpinBox *sb = new QSpinBox(parent);
215  sb->setFrame(false);
216  sb->setMaximum(INT_MAX);
217  return sb; }
218  case QVariant::Int: {
219  QSpinBox *sb = new QSpinBox(parent);
220  sb->setFrame(false);
221  sb->setMinimum(INT_MIN);
222  sb->setMaximum(INT_MAX);
223  return sb; }
224 #endif
225 #ifndef QT_NO_DATETIMEEDIT
226  case QVariant::Date: {
227  QDateTimeEdit *ed = new QDateEdit(parent);
228  ed->setFrame(false);
229  return ed; }
230  case QVariant::Time: {
231  QDateTimeEdit *ed = new QTimeEdit(parent);
232  ed->setFrame(false);
233  return ed; }
234  case QVariant::DateTime: {
235  QDateTimeEdit *ed = new QDateTimeEdit(parent);
236  ed->setFrame(false);
237  return ed; }
238 #endif
239  case QVariant::Pixmap:
240  return new QLabel(parent);
241 #ifndef QT_NO_SPINBOX
242  case QVariant::Double: {
243  QDoubleSpinBox *sb = new QDoubleSpinBox(parent);
244  sb->setFrame(false);
245  sb->setMinimum(-DBL_MAX);
246  sb->setMaximum(DBL_MAX);
247  return sb; }
248 #endif
249 #ifndef QT_NO_LINEEDIT
250  case QVariant::String:
251  default: {
252  // the default editor is a lineedit
253  QExpandingLineEdit *le = new QExpandingLineEdit(parent);
256  le->setWidgetOwnsGeometry(true);
257  return le; }
258 #else
259  default:
260  break;
261 #endif
262  }
263  return 0;
264 }
void setWidgetOwnsGeometry(bool value)
int type
Definition: qmetatype.cpp:239
The QTimeEdit class provides a widget for editing times based on the QDateTimeEdit widget...
The QDateEdit class provides a widget for editing dates based on the QDateTimeEdit widget...
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
void setFrame(bool)
Definition: qcombobox.cpp:3465
QStyle * style() const
Definition: qwidget.cpp:2742
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
void setMinimum(double min)
Definition: qspinbox.cpp:830
The QDoubleSpinBox class provides a spin box widget that takes doubles.
Definition: qspinbox.h:126
The QSpinBox class provides a spin box widget.
Definition: qspinbox.h:56
The QLabel widget provides a text or image display.
Definition: qlabel.h:55
void setFrame(bool)
Definition: qlineedit.cpp:514
void setMaximum(double max)
Definition: qspinbox.cpp:864
void setMinimum(int min)
Definition: qspinbox.cpp:425
#define INT_MAX
void setMaximum(int max)
Definition: qspinbox.cpp:456

◆ valuePropertyName()

QByteArray QDefaultItemEditorFactory::valuePropertyName ( QVariant::Type  type) const
virtual

Returns the property name used to access data for the given type of data.

Reimplemented from QItemEditorFactory.

Definition at line 266 of file qitemeditorfactory.cpp.

267 {
268  switch (type) {
269 #ifndef QT_NO_COMBOBOX
270  case QVariant::Bool:
271  return "currentIndex";
272 #endif
273 #ifndef QT_NO_SPINBOX
274  case QVariant::UInt:
275  case QVariant::Int:
276  case QVariant::Double:
277  return "value";
278 #endif
279 #ifndef QT_NO_DATETIMEEDIT
280  case QVariant::Date:
281  return "date";
282  case QVariant::Time:
283  return "time";
284  case QVariant::DateTime:
285  return "dateTime";
286 #endif
287  case QVariant::String:
288  default:
289  // the default editor is a lineedit
290  return "text";
291  }
292 }
int type
Definition: qmetatype.cpp:239

The documentation for this class was generated from the following file: