Hi
im trying to find out why i can’t see QTextEdit in item delegate , in my application so i remembered there is simple example in the examples
i did put simple QTextEdit in the sample code and it also didn’t show the QTextEdit why ? what im doing wrong
here is the modified code:

Qt Code:
  1. QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
  2. const QStyleOptionViewItem &/* option */,
  3. const QModelIndex &/* index */) const
  4. {
  5. //QSpinBox *editor = new QSpinBox(parent);
  6. //editor->setMinimum(0);
  7. //editor->setMaximum(100);
  8. QTextEdit *editor = new QTextEdit(parent);
  9. //editor->setGeometry(QRect(40, 30, 401, 31));
  10. editor->setLayoutDirection(Qt::LeftToRight);
  11. editor->setLocale(QLocale(QLocale::English, QLocale::UnitedStates));
  12. editor->setFrameShape(QFrame::WinPanel);
  13. editor->setLineWidth(0);
  14. editor->setReadOnly(true);
  15. editor->setText("This is text test!!1");
  16. return editor;
  17. }
  18. //! [1]
  19.  
  20. //! [2]
  21. void SpinBoxDelegate::setEditorData(QWidget *editor,
  22. const QModelIndex &index) const
  23. {
  24. /* int value = index.model()->data(index, Qt::EditRole).toInt();
  25.  
  26.   QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
  27.   spinBox->setValue(value);*/
  28. QTextEdit *textEdit = static_cast<QTextEdit*>(editor);
  29. textEdit->setText("This is text test!!1");
  30.  
  31.  
  32. }
  33. //! [2]
  34.  
  35. //! [3]
  36. void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
  37. const QModelIndex &index) const
  38. {
  39. /*QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
  40.   spinBox->interpretText();
  41.   int value = spinBox->value();
  42.  
  43.   model->setData(index, value, Qt::EditRole);*/
  44.  
  45. QTextEdit *textEdit = static_cast<QTextEdit*>(editor);
  46. }
  47. //! [3]
  48.  
  49. //! [4]
  50. void SpinBoxDelegate::updateEditorGeometry(QWidget *editor,
  51. const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
  52. {
  53. editor->setGeometry(option.rect);
  54. }
To copy to clipboard, switch view to plain text mode