johnnyturbo3 0 Newbie Poster

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:

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:

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:

#include <QtGui>
#include <QMessageBox>
#include <QString>
#include <QtSQL>
#include <QVector>
#include <QString>
#include <QSqlTableModel>
#include "MainWindow.h"
#include "VideoTab.h"
using namespace std;



MainWindow::MainWindow(){
	this->db = QSqlDatabase::addDatabase("QSQLITE", "myConnection");
	db.setDatabaseName("myDataBase.sqlite");
	db.open();
	createDisplay();

}




void MainWindow::createDisplay(){
	createModelView();
    QTableView *view = new QTableView();
    view->setModel(model);
    view->show();

     createTabView();
     QHBoxLayout *mainLayout = new QHBoxLayout();
     mainLayout->addWidget(view);
     mainLayout->addWidget(tabWidget);
     this->setLayout(mainLayout);


    setWindowTitle(tr("Menus"));
    setMinimumSize(160, 160);
    resize(1000, 400);

}





void MainWindow::createModelView(){
	this->model = new QSqlQueryModel();
	model->setHeaderData(0, Qt::Horizontal, tr(""));
	model->setHeaderData(1, Qt::Horizontal, tr(""));
	model->setQuery("Select * from video", db);
}




void MainWindow::createTabView(){
	videoTab = new VideoTab;
	tabWidget = new QTabWidget;
	tabWidget->addTab((videoTab), tr("Video"));
	//tabWidget->addTab(audioTab = new AudioTab, tr("Audio"));
	//tabWidget->addTab(transportTab = new TransportStreamTab, tr("Transport Stream"));
}


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

Thanks!