PDA

View Full Version : error: ‘paymentFrm’ was not declared in this scope



tttr
8th April 2011, 09:35
I'm a neophyte.
code
main,cpp

#include <qapplication.h>
#include "paymentfrm.h"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
paymentFrm w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}

paymentfrm.ui.h

#include <qsqldatabase.h>
#include<qsqlquery.h>
#include <qstring.h>
void paymentFrm::setDiscount_2()
{

QsqlDatabase *DB=QSqlDatabase::addDatabase("QMYSQL3");
if(!DB){
qWarning("Failed to connect to driver");
return;
}
DB->setDatabaseName("BookStore");
DB->setUserName("root");
DB->setPassword("9");
DB->setHostName("localhost");
if(!DB->open()){
qWarning("Failed to open TraniHelper database:"+DB->lastError().driverText());
qWarning(DB->lastError().databaseText());
return;
}

QSqlQuery query;
query.exec("select Levels from Customer where id="+VIPID_2.text());
query.next();
int level=query.value(0);
QString levels;
levels=levels.setNum(level);
query.exec("select Discount from Discount where Levels="+levels);
QString discount;
discount=discount.setNum(query.value(0));
Discount_2.setText(discount);

}


void paymentFrm::setTable()
{

QsqlDatabase *DB=QSqlDatabase::addDatabase("QMYSQL3");
if(!DB){
qWarning("Failed to connect to driver");
return;
}
DB->setDatabaseName("BookStore");
DB->setUserName("root");
DB->setPassword("9");
DB->setHostName("localhost");
if(!DB->open()){
qWarning("Failed to open TraniHelper database:"+DB->lastError().driverText());
qWarning(DB->lastError().databaseText());
return;
}
QSqlQuery query;
query.exec("select * from Book where ISBN="+ISBN_2.text());
query.next();
int i=Table.numRows();
Table.insertRows(i,1);


Table.setText(i,0,query.value(1));
Table.setText(i,1,query.value(2));
Table.setText(i,2,query.value(6));
Table.setText(i,3,Number_2.text());
Table.setText(i,4,Discount_2.text());

float num=Number_2.text().toFloat();
float discount=Discount_2.text().toFloat();
float total=num*discount*query.value(6);
QString Total;
Total=Total.setNum(total);
Table.setText(i,5,Total);
}


main.cpp: In function ‘int main(int, char**)’:
main.cpp:9: error: ‘paymentFrm’ was not declared in this scope
main.cpp:9: error: expected ‘;’ before ‘w’
main.cpp:10: error: ‘w’ was not declared in this scope

I don't know how to solve this problem.
Somebody please help me on this.
Thanks.

wysota
8th April 2011, 11:29
What does paymentfrm.h look like?

tttr
8th April 2011, 17:05
Oh, i know where the mistake is, thank you very much for enlightening me .

wysota
8th April 2011, 17:09
And it doesn't surprise you that you're including a file that doesn't exist? Maybe try including a file that does exist? And tell your teacher that Qt4 has been released 6 years ago and teaching students obsolete technologies such as Qt3 is probably not very interesting for them.