Hi,

I have a code design problem:

I have several classes
*MainWindow - holds 2 widgets, a QTableView Widget and a QTabWidget
*TabLayout - layout of the tab, comboboxes etc. Creates an instance of TabCode and connects its signals to it.
*VideoTab - contains the slots. Slots are called whenever a combobox is activated.
*SQLconnection - contains static functions to populate the combobox's options.


The program has two parts - a SQL table and a collection of tabbed options.
When a user selects an option from the tab's combobox, the SQL table's query needs to be changed to reflect the user's selection.

The GUI looks like this at the moment:
screenShot1.jpg


What I need is to be able to communicate from the VideoTab object to the MainWindow object whenever the user selects a combobox/whenever a slot is activated. I've attached a diagram to illustrate my ideas:
diagram.jpg



I've tried using a static method, but that would mean that I would have to also make QSQLQueryModel static in order to modify its setQuery() function. Here's the MainWindow code for reference:

Qt Code:
  1. #include <QtGui>
  2. #include <QMessageBox>
  3. #include <QString>
  4. #include <QtSQL>
  5. #include <QVector>
  6. #include <QString>
  7. #include <QSqlTableModel>
  8. #include "MainWindow.h"
  9. #include "VideoTab.h"
  10. using namespace std;
  11.  
  12.  
  13.  
  14. MainWindow::MainWindow(){
  15. this->db = QSqlDatabase::addDatabase("QSQLITE", "myConnection");
  16. db.setDatabaseName("myDataBase.sqlite");
  17. db.open();
  18. createDisplay();
  19.  
  20. }
  21.  
  22.  
  23.  
  24.  
  25. void MainWindow::createDisplay(){
  26. createModelView();
  27. QTableView *view = new QTableView();
  28. view->setModel(model);
  29. view->show();
  30.  
  31. createTabView();
  32. QHBoxLayout *mainLayout = new QHBoxLayout();
  33. mainLayout->addWidget(view);
  34. mainLayout->addWidget(tabWidget);
  35. this->setLayout(mainLayout);
  36.  
  37.  
  38. setWindowTitle(tr("Menus"));
  39. setMinimumSize(160, 160);
  40. resize(1000, 400);
  41.  
  42. }
  43.  
  44.  
  45.  
  46.  
  47.  
  48. void MainWindow::createModelView(){
  49. this->model = new QSqlQueryModel();
  50. model->setHeaderData(0, Qt::Horizontal, tr(""));
  51. model->setHeaderData(1, Qt::Horizontal, tr(""));
  52. model->setQuery("Select * from video", db);
  53. }
  54.  
  55.  
  56.  
  57.  
  58. void MainWindow::createTabView(){
  59. videoTab = new VideoTab;
  60. tabWidget = new QTabWidget;
  61. tabWidget->addTab((videoTab), tr("Video"));
  62. //tabWidget->addTab(audioTab = new AudioTab, tr("Audio"));
  63. //tabWidget->addTab(transportTab = new TransportStreamTab, tr("Transport Stream"));
  64. }
To copy to clipboard, switch view to plain text mode 

I hope I've clear stated my problem. I look forward to any comments or suggestion you peeps my have.

Thanks!