Results 1 to 6 of 6

Thread: QItemEditorFactory and custom Model

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Posts
    29
    Thanks
    8

    Default QItemEditorFactory and custom Model

    Hi,
    i tried to define my own delegate editor for a custom Tree model used with a standard QTreeView.

    seup is like this:
    Qt Code:
    1. QItemEditorCreatorBase *lineEditorCreator =
    2. new QStandardItemEditorCreator<LineEditorCreator>();
    3. factory->registerEditor(QVariant::String, lineEditorCreator);
    4. QItemEditorFactory::setDefaultFactory(factory);
    5.  
    6. SceneModel model("test.xml");
    7.  
    8. QTreeView view;
    9. view.setModel(&model);
    10. view.show();
    To copy to clipboard, switch view to plain text mode 
    this is the delegate (yes, it's only for testing):
    Qt Code:
    1. class LineEditorCreator : public QLineEdit
    2. {
    3. Q_OBJECT
    4. Q_PROPERTY(QString text READ text WRITE setText USER true)
    5.  
    6. public:
    7. LineEditorCreator(QWidget *widget = 0):
    8. QLineEdit(widget)
    9. {
    10. };
    11.  
    12. QString text() const
    13. {
    14. return QLineEdit::text();
    15. };
    16.  
    17. void setText(QString text)
    18. {
    19. QLineEdit::setText(text);
    20. };
    21.  
    22. };
    To copy to clipboard, switch view to plain text mode 

    i can also add the code for the model, but to my understanding it shouldn't interfere with the delegate.
    without the custom delegate, editing works fine (so, yes, items are editable), with the delegate just nothing happens (and it's functions aren't called at all).

    for testing purpose, i also tried with a standard QTreeWidget and the delegate works just fine there.

    are there any special additions to be made to an model, so it supports the delegate?
    Last edited by maximAL; 23rd November 2007 at 11:17.

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
  •  
Qt is a trademark of The Qt Company.