Results 1 to 5 of 5

Thread: Restrict QItemEditorFactory to one widget

  1. #1
    Join Date
    Mar 2012
    Location
    India
    Posts
    22
    Qt products
    Qt4
    Thanks
    3

    Default Restrict QItemEditorFactory to one widget

    Hi,

    I have a custom QDialog (say "MyDialog") with a QTableWidget to display my data.
    Now in MyDialog constructor I have the following code

    Qt Code:
    1. MyDialog::MyDialog(QWidget *parent) : QDialog(parent)
    2. {
    3. QItemEditorCreatorBase *myEditorCreator = new QStandardItemEditorCreator<MyItemEditor>();
    4. myFactory->registerEditor(QVariant::String, myEditorCreator );
    5. QItemEditorFactory::setDefaultFactory(myFactory);
    6.  
    7. setupTable();
    8. }
    To copy to clipboard, switch view to plain text mode 

    I have 2 queries regarding the code.
    Firstly Who is responsible for deleting myFactory ?
    Secondly, what is the scope of myFactory and hence the editor MyItemEditor ?
    In other words will a different QTableWidget in some other place also use this factory ?

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

    Default Re: Restrict QItemEditorFactory to one widget

    Quote Originally Posted by pratham_shah View Post
    Firstly Who is responsible for deleting myFactory ?
    Qt

    Secondly, what is the scope of myFactory and hence the editor MyItemEditor ?
    Scope of the factory is the whole application unless you delete it yourself. Scope of the editor is the time it takes to edit a single cell in the table.

    In other words will a different QTableWidget in some other place also use this factory ?
    Yes, since you have set it as default.
    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.


  3. #3
    Join Date
    Mar 2012
    Location
    India
    Posts
    22
    Qt products
    Qt4
    Thanks
    3

    Default Re: Restrict QItemEditorFactory to one widget

    So then how to restrict the QItemEditorFactory to one particular widget ?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Restrict QItemEditorFactory to one widget

    You create a QStyledItemDelegate that you apply to only the one view.

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

    Default Re: Restrict QItemEditorFactory to one widget

    Apply a custom item delegate on the widget and set the item editor factory on that delegate directly instead of setting it as default.
    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.


  6. The following user says thank you to wysota for this useful post:

    pratham_shah (21st May 2013)

Similar Threads

  1. QItemEditorFactory and QStyledDelegate
    By Qtonimo in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2012, 18:51
  2. Replies: 0
    Last Post: 29th April 2011, 08:52
  3. QItemEditorFactory for QList.
    By hickscorp in forum Qt Programming
    Replies: 1
    Last Post: 29th October 2010, 12:32
  4. Replies: 1
    Last Post: 28th May 2010, 11:33
  5. Q_ENUMS, QItemEditorFactory
    By Kunchok in forum Qt Programming
    Replies: 8
    Last Post: 21st January 2008, 12:20

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.