I am a bit confused with Qt's onClick handling. I have a class which looks like this:
class DatabaseManager : public QObject
{
Q_OBJECT;
private:
QSqlDatabase db;
public slots:
bool openDB(const QString& path);
};
And I have a class which handles the click on the button:
Click::Click(QWidget *parent) : QWidget(parent){
QPushButton *create = new QPushButton("Create database", this);
create->setGeometry(50,100,100,100);
connect(create, SIGNAL(clicked()), this, SLOT(openDB("/home/peter/database.db")));
}
main.cpp
int main(int argc,char **argv){
QApplication *app = new QApplication(argc, argv);
QPushButton btn;
DatabaseManager db;
btn.move(300,300);
btn.resize(250,250);
btn.setWindowTitle("Dibli");
btn.show();
return app->exec();
}
How could I tell to the click handler, that I want to use a specific DatabaseManager object's openDB function? Because it doesn't create the file, if I click on it.
I've updated the code.