Results 1 to 3 of 3

Thread: How to use custom widget editor with QItemDelegate

  1. #1
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question How to use custom widget editor with QItemDelegate

    Hello,

    In my project, i need to populate a ListView with different item. Those items can have différent nature, and need a custom widget for drawing and editing.

    I have build a custom widget (Widget_CarteFille_Gpio) with QDesigner (1 layout, 2 label, 2 combo-box)

    Qt Code:
    1. Widget_CarteFille_Gpio::Widget_CarteFille_Gpio (QWidget *parent) :
    2. QWidget (parent)
    3. {
    4. setupUi (this);
    5. }
    To copy to clipboard, switch view to plain text mode 

    Next, i try to subclass a QItemDelegate who build my new widget for the editing.

    Qt Code:
    1. QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
    2. {
    3. Widget_CarteFille_Gpio *editor = new Widget_CarteFille_Gpio (parent);
    4. return editor;
    5. }
    To copy to clipboard, switch view to plain text mode 

    I build the project, and exec the application !
    When I double click on the item my widget is not show !

    I read this exemple : http://doc.qtsoftware.com/4.5/itemvi...rdelegate.html but they draw directly on a widget, this is little different of my problem.

    If someone have a code exemple about draw a custom widget for viewing/editing in a ListView. I was very interresting.

    Thanks
    Apologize for my English !

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to use custom widget editor with QItemDelegate

    subclass QStyledItemDelegateinstead of QItemDelegate..also you should read about QItemEditorCreator, QItemEditorCreatorBaseand QItemEditorFactory..this will give you more knowledge about editors and you'd be able to solve problem yourself

  3. #3
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to use custom widget editor with QItemDelegate

    Thanks, i will read

Similar Threads

  1. QItemDelegate and custom widget
    By nifei in forum Qt Programming
    Replies: 2
    Last Post: 10th November 2008, 01:30
  2. Custom Widget - First Steps
    By sekatsim in forum Qt Programming
    Replies: 8
    Last Post: 26th June 2008, 18:19
  3. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 15:06
  4. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 16:38
  5. Simple custom widget won't size properly
    By MrGarbage in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 14:12

Tags for this Thread

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.