Hello every one. I want to use a QPushButton on QWizardPage. I have implemented the qwizard pages and added QPushButton as follows in the code bellow. When I click the button, the signal and slot connection does not work. Any idea on how to go around it? Thanks in advance for your response.
class DatabasePage : public QWizardPage
{
public:
DatabasePage();
int nextId() const;
private slots:
void connectionTest();
private:
QPushButton *testConnBttn;
};
DatabasePage::DatabasePage()
{
.....
testConnBttn = new QPushButton(tr("Test connection"));
QHBoxLayout *bttnLayout = new QHBoxLayout;
bttnLayout->addStretch();
bttnLayout->addWidget(testConnBttn);
setLayout(bttnLayout);
connect(testConnBttn, SIGNAL(clicked()), this, SLOT(connectionTest()));
}
void DatabasePage::connectionTest()
{
QMessageBox::information(this,"WATCH","Error");
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName( "localhost");
db.setDatabaseName( "test" );
db.setUserName( "root" );
db.setPassword( "hqo" );
if ( !db.open() )
{
QMessageBox::information(this,"WATCH",db.lastError().text());
}
}
↧