Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Handle to factory edit widget



  • I want insert my own editor widget into a QTableView. I am trying to follow the lone example Qt offers which does it for a Color ComboBox.

    My issue is that I want a handle to the edit widget. IN the code below I want to get a pointer to ColorListEditor. Say for instance I want to change the colours dynamically and so want a pointer to the widget so I can call a method like 'resetColors(QStrList colors);

    Does anyone know how I can get such a handle to the created widget.

    Thanks

    @QItemEditorFactory *factory = new QItemEditorFactory;

    QItemEditorCreatorBase *colorListCreator =
        new QStandardItemEditorCreator<ColorListEditor>();
    
    // How do I get a handle to the newly created ColorListEditor ?
    
    factory->registerEditor(QVariant::Color, colorListCreator);
    
    QItemEditorFactory::setDefaultFactory(factory);@

  • Lifetime Qt Champion

    Hi,

    From quick look to the classes you would have to keep a pointer to your editor creator, update the color list there and apply it each time you create a new editor or you could create a QStyleItemDelegate where you set the list in createEditor.

    Hope it helps



  • Thanks

    I think I will just create a separate edit area below the table.


Log in to reply