Results 1 to 4 of 4

Thread: error: ‘paymentFrm’ was not declared in this scope

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Post error: ‘paymentFrm’ was not declared in this scope

    I'm a neophyte.
    code
    main,cpp
    Qt Code:
    1. #include <qapplication.h>
    2. #include "paymentfrm.h"
    3. int main( int argc, char ** argv )
    4. {
    5. QApplication a( argc, argv );
    6. paymentFrm w;
    7. w.show();
    8. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    paymentfrm.ui.h
    Qt Code:
    1. #include <qsqldatabase.h>
    2. #include<qsqlquery.h>
    3. #include <qstring.h>
    4. void paymentFrm::setDiscount_2()
    5. {
    6.  
    7. QsqlDatabase *DB=QSqlDatabase::addDatabase("QMYSQL3");
    8. if(!DB){
    9. qWarning("Failed to connect to driver");
    10. return;
    11. }
    12. DB->setDatabaseName("BookStore");
    13. DB->setUserName("root");
    14. DB->setPassword("9");
    15. DB->setHostName("localhost");
    16. if(!DB->open()){
    17. qWarning("Failed to open TraniHelper database:"+DB->lastError().driverText());
    18. qWarning(DB->lastError().databaseText());
    19. return;
    20. }
    21.  
    22. QSqlQuery query;
    23. query.exec("select Levels from Customer where id="+VIPID_2.text());
    24. query.next();
    25. int level=query.value(0);
    26. QString levels;
    27. levels=levels.setNum(level);
    28. query.exec("select Discount from Discount where Levels="+levels);
    29. QString discount;
    30. discount=discount.setNum(query.value(0));
    31. Discount_2.setText(discount);
    32.  
    33. }
    34.  
    35.  
    36. void paymentFrm::setTable()
    37. {
    38.  
    39. QsqlDatabase *DB=QSqlDatabase::addDatabase("QMYSQL3");
    40. if(!DB){
    41. qWarning("Failed to connect to driver");
    42. return;
    43. }
    44. DB->setDatabaseName("BookStore");
    45. DB->setUserName("root");
    46. DB->setPassword("9");
    47. DB->setHostName("localhost");
    48. if(!DB->open()){
    49. qWarning("Failed to open TraniHelper database:"+DB->lastError().driverText());
    50. qWarning(DB->lastError().databaseText());
    51. return;
    52. }
    53. QSqlQuery query;
    54. query.exec("select * from Book where ISBN="+ISBN_2.text());
    55. query.next();
    56. int i=Table.numRows();
    57. Table.insertRows(i,1);
    58.  
    59.  
    60. Table.setText(i,0,query.value(1));
    61. Table.setText(i,1,query.value(2));
    62. Table.setText(i,2,query.value(6));
    63. Table.setText(i,3,Number_2.text());
    64. Table.setText(i,4,Discount_2.text());
    65.  
    66. float num=Number_2.text().toFloat();
    67. float discount=Discount_2.text().toFloat();
    68. float total=num*discount*query.value(6);
    69. QString Total;
    70. Total=Total.setNum(total);
    71. Table.setText(i,5,Total);
    72. }
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by wysota; 8th April 2011 at 12:29. Reason: missing [code] tags

Similar Threads

  1. Variable not declared in this scope error
    By hojoff79 in forum Newbie
    Replies: 1
    Last Post: 30th December 2010, 01:29
  2. Replies: 10
    Last Post: 22nd September 2010, 07:20
  3. Replies: 2
    Last Post: 16th July 2010, 08:17
  4. glutSolidSphere was not declared in this scope error
    By nuts_fever_007 in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2009, 05:56
  5. error: 'connect' was not declared in this scope ??
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 14th January 2007, 16:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.