#include "fencene.h"
#include "ui_fencene.h"
FenCene
::FenCene(QWidget *parent
) : ui(new Ui::FenCene)
{
ui->setupUi(this);
bttoncreate
= new QPushButton("Cahier Electronique de Note de L'Enseignant Principal (CEN_EP)");
bttoncreate
->setFont
(QFont("Times New Roman",
20));
bttoncreate->setCursor(Qt::PointingHandCursor);
connect(bttoncreate, &QPushButton::clicked, this, &FenCene::newfiledb);
}
FenCene::~FenCene()
{
delete ui;
}
void FenCene::newfiledb() // SLot no connected....
{
db.setDatabaseName("......"); //Each User give an name at database
db.setHostName("local"); //i don't know if it's necessary
if(!db.open())
{
QMessageBox::critical(0, qApp
->tr
("Cannot open database"),
qApp->tr("La connexion n'est pas correctement établis à la base de donnée"
"Reprenez le processus.\n\n"
"Cliquer sur annuler pour quitter");
return false ; //i don't know if it's necessary
}
query.exec("create table student (ID int, "
"Nomprenoms varchar(100), "
"DateDeNaissance varchar(20), "
"Sexe varcher (1)"
"Varchar(20), "
"matiere(20),"
"notei1 int, "
"notei2 int, "
"notei3 int, "
"notei4 int, "
"notei5 int, "
"noted1 int, "
"noted2 int, "
"Comment bool (15)))"); // I did not put Moy Interro, Moy Sem and Moy Coef into the database.
//table student + table class + Table subject + table note = student record
model->setTable("Student");
model->select();
model->removeColumn(0);
model->setHeaderData(0, Qt::Horizontal, "Nom(s) & Prénom(s)");
model->setHeaderData(1, Qt::Horizontal, "Sexe");
model->setHeaderData(2, Qt::Horizontal, "Statut");
model->setHeaderData(3, Qt::Horizontal, "Coef");
model->setHeaderData(4, Qt::Horizontal, "1è");
model->setHeaderData(5, Qt::Horizontal, "2è");
model->setHeaderData(6, Qt::Horizontal, "3è");
model->setHeaderData(7, Qt::Horizontal, "4è");
model->setHeaderData(8, Qt::Horizontal, "5è");
model->setHeaderData(9, Qt::Horizontal, "Moy Interro"); //No Include in database
model->setHeaderData(10, Qt::Horizontal, "1è");
model->setHeaderData(11, Qt::Horizontal, "2è");
model->setHeaderData(12, Qt::Horizontal, "Moy Sem"); // No Include in database
model->setHeaderData(13, Qt::Horizontal, "Moy Coef"); // No Include in database
model->setHeaderData(14, Qt::Horizontal, "Mentions");
view->setModel(model);
v->addWidget(view);
return true;
}
#include "fencene.h"
#include "ui_fencene.h"
FenCene::FenCene(QWidget *parent) :
QWidget(parent),
ui(new Ui::FenCene)
{
ui->setupUi(this);
bttoncreate = new QPushButton("Cahier Electronique de Note de L'Enseignant Principal (CEN_EP)");
bttoncreate->setFont(QFont("Times New Roman", 20));
bttoncreate->setCursor(Qt::PointingHandCursor);
connect(bttoncreate, &QPushButton::clicked, this, &FenCene::newfiledb);
}
FenCene::~FenCene()
{
delete ui;
}
void FenCene::newfiledb() // SLot no connected....
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("......"); //Each User give an name at database
db.setHostName("local"); //i don't know if it's necessary
if(!db.open())
{
QMessageBox::critical(0, qApp->tr("Cannot open database"),
qApp->tr("La connexion n'est pas correctement établis à la base de donnée"
"Reprenez le processus.\n\n"
"Cliquer sur annuler pour quitter");
return false ; //i don't know if it's necessary
}
QSqlQuery query; //Student Only
query.exec("create table student (ID int, "
"Nomprenoms varchar(100), "
"DateDeNaissance varchar(20), "
"Sexe varcher (1)"
"Varchar(20), "
"matiere(20),"
"notei1 int, "
"notei2 int, "
"notei3 int, "
"notei4 int, "
"notei5 int, "
"noted1 int, "
"noted2 int, "
"Comment bool (15)))"); // I did not put Moy Interro, Moy Sem and Moy Coef into the database.
//table student + table class + Table subject + table note = student record
model = new QSqlTableModel;
model->setTable("Student");
model->setEditStrategy(QSqlTableModel::OnFieldChange);
model->select();
model->removeColumn(0);
model->setHeaderData(0, Qt::Horizontal, "Nom(s) & Prénom(s)");
model->setHeaderData(1, Qt::Horizontal, "Sexe");
model->setHeaderData(2, Qt::Horizontal, "Statut");
model->setHeaderData(3, Qt::Horizontal, "Coef");
model->setHeaderData(4, Qt::Horizontal, "1è");
model->setHeaderData(5, Qt::Horizontal, "2è");
model->setHeaderData(6, Qt::Horizontal, "3è");
model->setHeaderData(7, Qt::Horizontal, "4è");
model->setHeaderData(8, Qt::Horizontal, "5è");
model->setHeaderData(9, Qt::Horizontal, "Moy Interro"); //No Include in database
model->setHeaderData(10, Qt::Horizontal, "1è");
model->setHeaderData(11, Qt::Horizontal, "2è");
model->setHeaderData(12, Qt::Horizontal, "Moy Sem"); // No Include in database
model->setHeaderData(13, Qt::Horizontal, "Moy Coef"); // No Include in database
model->setHeaderData(14, Qt::Horizontal, "Mentions");
QTableView *view = new QTableView;
view->setModel(model);
QVBoxLayout *v = new QVBoxLayout;
v->addWidget(view);
return true;
}
To copy to clipboard, switch view to plain text mode
Bookmarks