Hello!
Thanks to you I make it work. In fact, I get rid of all overrides (createCellWidget, insertWidget, etc. ) except for beginEdit() and endEdit(). I don't know how good this solution is, but, as I mentioned before, it works.
To ensure I didn't forget anything, I'll provide code for beginEnd() and endEdit() here.
QWidget * QtsDataTable
::beginEdit ( int row,
int col,
bool replace
) {
ensureCellVisible( row, col );
/*here goes instantiating, setting values, etc.*/
if(w != 0)
{
w->installEventFilter ( this );
QRect cr
= cellGeometry
( row, col
);
w->resize( cr.size() );
moveChild( w, cr.x(), cr.y() );
w->setActiveWindow();
w->show();
w->setFocus();
}
updateCell( row , col );
}
QWidget * QtsDataTable::beginEdit ( int row, int col, bool replace )
{
ensureCellVisible( row, col );
QWidget * w = 0;
/*here goes instantiating, setting values, etc.*/
if(w != 0)
{
w->installEventFilter ( this );
QRect cr = cellGeometry( row, col );
w->resize( cr.size() );
moveChild( w, cr.x(), cr.y() );
w->setActiveWindow();
w->show();
w->setFocus();
}
updateCell( row , col );
}
To copy to clipboard, switch view to plain text mode
void QtsDataTable::endEdit ( int row, int col, bool accept, bool replace )
{
/*here goes setting values, etc.*/
if(w != 0)
{
w->hide();
w->removeEventFilter( this );
}
setEditMode( QTable::NotEditing, -1, -1);
viewport()->setFocus();
updateCell( row, col);
}
void QtsDataTable::endEdit ( int row, int col, bool accept, bool replace )
{
QWidget * w = 0;
/*here goes setting values, etc.*/
if(w != 0)
{
w->hide();
w->removeEventFilter( this );
}
setEditMode( QTable::NotEditing, -1, -1);
viewport()->setFocus();
updateCell( row, col);
}
To copy to clipboard, switch view to plain text mode
Bookmarks