Results 1 to 2 of 2

Thread: Trying to change spinboxdelegate example from spinbox to QTextEdit but it dosn’t show

  1. #1
    Join Date
    May 2009
    Posts
    83

    Default Trying to change spinboxdelegate example from spinbox to QTextEdit but it dosn’t show

    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 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Trying to change spinboxdelegate example from spinbox to QTextEdit but it dosn’t

    So what does it show when you enter edit mode?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qt Designer Change active .ui file || Show a second window
    By MrRump in forum Qt Tools
    Replies: 4
    Last Post: 5th June 2010, 19:57
  2. Change margin on QTextEdit print()
    By Dii in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2008, 22:45
  3. QTextEdit does not show!!!!
    By MarkoSan in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2008, 15:13
  4. Display a file from Directory tree to show in QTextEdit
    By vvdounai in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2007, 13:43
  5. Replies: 2
    Last Post: 9th March 2007, 23:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.