i tried to entre data from a form " means from QlineEdit as integer "
the programm is compiled successfully but when i open the form and entre data , the programm crach
her's the erreur
Object::connect: No such slot FenArticle::chercheParFamille() in ..\stockmanagement\fenarticle.cpp:113
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
hers my code *
#include "fenajoutearticle.h"
#include <QIntValidator>
#include <QValidator>
FenAjouteArticle::FenAjouteArticle(QWidget *parent) :
QWidget(parent)
{
resize(500,450);
setWindowModality(Qt::ApplicationModal);
// init member widgets
//*****************************Signals SLots ******************************//
signalSlots();
//***********************************Base de donnée Traitement***********************************//
db = new QSqlDatabase;
*db = QSqlDatabase::addDatabase("QSQLITE") ;
db->setHostName("localhost");
db->setDatabaseName("gestionstockDB.db");
db->setPassword("");
db->setUserName("");
db->open();
if(!db->open())
QMessageBox::critical(this,"Erreur","Erreur connexion base de données") ;
else{
QSqlQuery *chercheParFamilleQuery = new QSqlQuery("select Famille from Produit");
SelectFamille->clear();
while(chercheParFamilleQuery->next())
SelectFamille->addItem(chercheParFamilleQuery->value(0).toString());
QSqlQuery *chercheParUniteQuery = new QSqlQuery("select Unite from Produit");
selectUnit->clear();
while(chercheParUniteQuery->next())
selectUnit->addItem(chercheParUniteQuery->value(0).toString());
}
// basic layouting
}
void FenAjouteArticle::signalSlots()
{
connect(buttonOkUtilisateur,SIGNAL(clicked()),this,SLOT(ajoutDonne())) ;
connect(buttonAnnulerUtilisateur,SIGNAL(clicked()),this,SLOT(close())) ;
}
//********************* Signal Slots coeurs ***********************************//
void FenAjouteArticle::ajoutDonne()
{
if(db->open())
{
QSqlQuery *ajouterDonneeQuery = new QSqlQuery;
ajouterDonneeQuery->prepare("insert into Produit (Reference,Designation,localisation,Famille,Qte_min,Qte_max,Qte_stock,Unite,Prix_achat,Prix_vente) VALUES(:ref,:design,:local,:fam,:qtmin,:qtmax,:qtstock ,:unite,:pachat,:pvente)");
//QString Stock = champStockInit->text();
ajouterDonneeQuery->bindValue(":ref",champRef->text()); // QlineEdit
ajouterDonneeQuery->bindValue(":design",champDesignation->text()); // QlineEdit
ajouterDonneeQuery->bindValue(":local",champLocalisation->text()); // QlineEdit
ajouterDonneeQuery->bindValue(":fam","fam"); // QcomboBox
ajouterDonneeQuery->bindValue(":qtmin",200); // QlineEdit
ajouterDonneeQuery->bindValue(":qtmax",20); // QlineEdit
ajouterDonneeQuery->bindValue(":qtstock",20); // QlineEdit
ajouterDonneeQuery->bindValue(":unite","unite"); // QlineEdit
ajouterDonneeQuery->bindValue(":pachat",20); // QlineEdit
ajouterDonneeQuery->bindValue(":pvente",champPrixVente->text()); // QlineEdit
ajouterDonneeQuery->exec();
}
}