I'm trying to save a Window form
inside a QTableWidget
table.
int rows = 0;
int columns = 0;
QTableWidget cellTable;
What I'm doing is that I first set the rows and columns
cellTable.setRowCount(++rows);
cellTable.setRowCount(++columns);
For every time I increase the rows, I call this code
for(int i = 0; i < rows; i++)
cellTable.setCellWidget(rows-1, i, new DatabaseMeasurementType());
For every time I increase the columns, I call this code
for(int i = 0; i < rows; i++)
cellTable.setCellWidget(i, columns-1, new DatabaseMeasurementType());
It works if I replace the new DatabaseMeasurementType()
with new QPushButton()
. But then all the fields will be buttons. For the moment, I just want to store a window form inside the setCellWidget
. Yes, new DatabaseMeasurementType()
is a widget form.
Problem:
When I call this code (dynamic cast)
DatabaseMeasurementType *databaseMeasurementType = static_cast<DatabaseMeasurementType*>(cellTable.cellWidget(row, column));
databaseMeasurementType->show();
Or this code (static cast)
DatabaseMeasurementType *databaseMeasurementType = dynamic_cast<DatabaseMeasurementType*>(cellTable.cellWidget(row, column));
databaseMeasurementType->show();
Then it crash. Why?
My idea is to have a large 2D matrix where I can store windows forms. Then I only need to call x
and y
arguments for the 2D matrix to recieve the windows form.