我有一些 GUI(显示使用中的账单QTableWidget
),我在文件中的MainWindow
类之外实现了这些。checkout.cpp
我在连接checkout.cpp
. 由于MainWindow
该类继承自QMainWindow
,因此我可以将适当的槽函数与 this 对象相关联。
如何在CheckOut
不继承自 QMainWindow
或的类中执行此操作QWidget
?
编辑(代码):
CheckOut::CheckOut(string token)The CheckOut class does not inherit any other class. I am getting error: /home/sudeep/Desktop/mesonero project/mesonero-build-desktop-Qt_4_8_1_in_PATH__System__Release/../mesonero/management.cpp:29: error: no matching function for call to 'QObject::connect(QPushButton*&, const char [11], Management* const, const char [8])'
{ CustomerToken = token;
if(!findCustomer())
QMessageBox::critical(0,QObject::tr("Check Out"),"Invalid Customer Token");
else{
generateBill();
provideDiscount();
QPushButton *payButton = new QPushButton("Pay");
QObject::connect(payButton,SIGNAL(clicked()),this,SLOT(deleteCustomer()));
CustomerBill->layout()->addWidget(payButton);
}
}
void CheckOut::deleteCustomer()
{
DatabaseManager *dbm = DatabaseManager::Instance();
QSqlQuery query("DELETE FROM `Residing_Customer` WHERE Customer_Token = '"+QString::fromStdString(CustomerToken)+"'",dbm->db);
query.exec();
CustomerBill->close();
}
编辑(错误):
/home/sudeep/Desktop/mesonero project/mesonero-build-desktop-Qt_4_8_1_in_PATH__System__Release/../mesonero/checkout.cpp:29: error: no matching function for call to 'QObject::connect(QPushButton*&, const char [11], CheckOut* const, const char [8])'