newbie
22nd August 2006, 14:26
hi i need help with model view programming!!!
i have little databe of peoples, and i use Q3Table to show my table in new widget
but my "hard" teacher wants to do it with model/view
i dont know how can i do it and i have only few days for it.. can someone help me with this please ??:confused:
i really thanks in advance
show_table is the important function here.. and peoples are container type of "vector"
and sry for my bad english..
MainWindow.cpp
.
.
.
#include "ui/ui_MainWindow.h"
#include "MainWindow.h"
#include <Q3Table>
#include <QRegExp>
#include <QSpinBox>
#include <vector>
.
.
.
#include "ui/ui_Tab.h"
#include "Tab.h"
#include "Tab.cpp"
using namespace std;
vector <osoba> people;
.
.
.
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setupUi(this);
.
.
.
count=people.size();
connectSlots();
}
void MainWindow::show_table()
{
Tab *my_table = new Tab;
my_table->table->setNumRows(people.size());
my_table->table->setColumnWidth ( 0, 115 );
my_table->table->setColumnWidth ( 1, 115 );
my_table->table->setColumnWidth ( 2, 70 );
for( int row= 0; row < count ; row++)
{
my_table->table->setText(row,0,people[row].sur_name);
my_table->table->setText(row,1,people[row].first_name);
my_table->table->setText(row,2,people[row].number);
my_table->table->sortColumn(0,TRUE,TRUE);
}
my_table->table->setReadOnly(TRUE);
my_table->show();
}
.
.
.
void MainWindow::quit()
{
qApp->closeAllWindows();
}
and this is my screen of this pgm.. http://ki.ujep.cz/~minsky/screenqt.jpg
i have little databe of peoples, and i use Q3Table to show my table in new widget
but my "hard" teacher wants to do it with model/view
i dont know how can i do it and i have only few days for it.. can someone help me with this please ??:confused:
i really thanks in advance
show_table is the important function here.. and peoples are container type of "vector"
and sry for my bad english..
MainWindow.cpp
.
.
.
#include "ui/ui_MainWindow.h"
#include "MainWindow.h"
#include <Q3Table>
#include <QRegExp>
#include <QSpinBox>
#include <vector>
.
.
.
#include "ui/ui_Tab.h"
#include "Tab.h"
#include "Tab.cpp"
using namespace std;
vector <osoba> people;
.
.
.
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setupUi(this);
.
.
.
count=people.size();
connectSlots();
}
void MainWindow::show_table()
{
Tab *my_table = new Tab;
my_table->table->setNumRows(people.size());
my_table->table->setColumnWidth ( 0, 115 );
my_table->table->setColumnWidth ( 1, 115 );
my_table->table->setColumnWidth ( 2, 70 );
for( int row= 0; row < count ; row++)
{
my_table->table->setText(row,0,people[row].sur_name);
my_table->table->setText(row,1,people[row].first_name);
my_table->table->setText(row,2,people[row].number);
my_table->table->sortColumn(0,TRUE,TRUE);
}
my_table->table->setReadOnly(TRUE);
my_table->show();
}
.
.
.
void MainWindow::quit()
{
qApp->closeAllWindows();
}
and this is my screen of this pgm.. http://ki.ujep.cz/~minsky/screenqt.jpg