View Full Version : Problem refreshing the contents of a QTable [Qt 3.3.8]

7th October 2008, 19:08
Hi all,

I have a problem refreshing the content of a QTable.
I'm simply creating a table with a few rows and columns. The last column contains QToolButtons for each row.

The problem is that the first time the table is shown, if the last column is not visible, then the tool buttons in such column are visible but in a wrong position. If I scroll to the right the view then the tool buttons are put in the correct position. (see the attached images)

It seems a contents refresh problem. But I'm not sure.

This is the code I'm using:

MyTable::MyTable(QWidget * parent, const char * name)
: QTable(parent, name)

QStringList columnNames;
columnNames << "Variable Name";
columnNames << "Variable Value";
columnNames << "Variable Description";
columnNames << "";

void MyTable::setVariablesList( const MyVar &varsList )
setNumRows( varsList.count() );

QToolButton *pButton;
MyEditor *pVarEditor;
QValueList<MyVar>::const_iterator it = varsList.begin();
int i = 0;
for( ; it != varsList.end(); it++, i++ )
pVarEditor = MyVarEditorFactory::create(this, *it);
pButton = new QToolButton(this);

setText(i, 0, (*it).sName);
setText(i, 1, (*it).sDescription);
setCellWidget(i, 2, dynamic_cast<QWidget *>(pVarEditor) );
setCellWidget(i, 3, pButton);

for( int i = 0; i < numCols(); i++ )

I would be very glad if you can help me solving such problems.
Thanks a lot in advance!