Hello,

I am using QT Creator. I added a QTableWidget using the .ui editor. When I run the project the widget shows up.
I now want to programmatically add a few rows to the QTableWidget.
I am confused because in the mainwindow.cpp/.h I see no reference to my QTableWidget.

1) How is the QTableWidget actually showing up in the UI if it is not even mentioned in the mainwindow.cpp/.h?
2) Is there a way to get the mainwindow.cpp/.h to synch up with the .ui file?

thanks!
code below

mainwindow.h
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5.  
  6. namespace Ui {
  7. class MainWindow;
  8. }
  9.  
  10. class MainWindow : public QMainWindow {
  11. Q_OBJECT
  12. public:
  13. MainWindow(QWidget *parent = 0);
  14. ~MainWindow();
  15.  
  16. protected:
  17. void changeEvent(QEvent *e);
  18.  
  19. private:
  20. Ui::MainWindow *ui;
  21. };
  22.  
  23. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent) :
  5. QMainWindow(parent),
  6. ui(new Ui::MainWindow)
  7. {
  8. ui->setupUi(this);
  9. /*
  10.  
  11.   * this is what I want to do eventually
  12.  
  13.   int numberDatasets = 5;
  14.   for(int i=0; i<numberDatasets; ++i) {
  15.   int row = datasetMain_table->rowCount();
  16.   datasetMain_table->insertRow(row);
  17.   // name, description, date, notes
  18.   datasetMain_table->setItem(row, 0, "dataset name blah.dat");
  19.   datasetMain_table->setItem(row, 1, "This is a test dataset from 1/1/1/1/15953 hb blah");
  20.   datasetMain_table->setItem(row, 2, "6/3/86");
  21.   datasetMain_table->setItem(row, 3, "We have this run on 1,2,3");
  22.   }*/
  23. }
  24.  
  25. MainWindow::~MainWindow()
  26. {
  27. delete ui;
  28. }
  29.  
  30. void MainWindow::changeEvent(QEvent *e)
  31. {
  32. QMainWindow::changeEvent(e);
  33. switch (e->type()) {
  34. case QEvent::LanguageChange:
  35. ui->retranslateUi(this);
  36. break;
  37. default:
  38. break;
  39. }
To copy to clipboard, switch view to plain text mode 
}