Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2179

Q3Table : headers are not updated correctly after setting dimensions to 0x0

    XMLWordPrintable

Details

    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

      { _table->setNumRows( 2 ); _table->setNumCols( 2 ); rowLabels.append( "row0" ); rowLabels.append( "row1" ); colLabels.append( "col0" ); colLabels.append( "col1" ); _table->setRowLabels( rowLabels ); _table->setColumnLabels( colLabels ); _table->setText( 0, 0, "AA" ); _table->setText( 0, 1, "AB" ); _table->setText( 1, 0, "BA" ); _table->setText( 1, 1, "BB" ); }


      }

      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();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            smd Jan Arve
            dettman Dean Dettman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes