Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.4.0
-
None
Description
When setting a Q3Table to zero rows/cols the old header labels can be removed by setting them to an empty QStringList, however they are not restored correctly when columns are added back in again.
This can be seen with the following small sample:
#include <QtGui>
#include <Qt3Support>
class Widget : public QWidget {
Q_OBJECT;
public:
Widget()
{ QVBoxLayout* layout = new QVBoxLayout( this ); _table = new Q3Table( this ); layout->addWidget( _table ); QPushButton* button = new QPushButton( "Click me", this ); connect( button, SIGNAL( clicked() ), SLOT( slotClicked() ) ); layout->addWidget( button ); }
private slots:
// Toggles table dimensions
void slotClicked() {
QStringList rowLabels;
QStringList colLabels;
if( _table->numCols() > 1 )
{ //#if 1 // Empty, does not work properly _table->setNumRows( 0 ); _table->setNumCols( 0 ); _table->setRowLabels( rowLabels ); _table->setColumnLabels( colLabels ); //#else // Non-empty, works okay // // _table->setNumRows( 1 ); // _table->setNumCols( 1 ); // // rowLabels.append( "row0" ); // colLabels.append( "col0" ); // // _table->setRowLabels( rowLabels ); // _table->setColumnLabels( colLabels ); // // _table->setText( 0, 0, "AA" ); //#endif }
else
}
private:
Q3Table* _table;
};
//This moc name must match the name of the file to get objects into a single file
#include "main.moc"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Widget *myWidget = new Widget();
myWidget->show();
return app.exec();
}