Hello.
I've started using QT recently and I quite like it so far. However I can't get past this error.
In Povezava.ui.h I have setup connection to database like this:
void Povezava::Connect_clicked()
{
int indeks = tipbaze->currentItem();
if (indeks==0) {driver ="QMYSQL3";}
if (indeks==1) {driver ="QPSQL7";}
if (indeks==2) {driver ="QODBC3";}
baza->setHostName ( hostm );
baza->setDatabaseName ( namem );
baza->setUserName ( userm );
baza->setPassword ( passm );
bool ok = baza->open();
}
void Povezava::Connect_clicked()
{
int indeks = tipbaze->currentItem();
if (indeks==0) {driver ="QMYSQL3";}
if (indeks==1) {driver ="QPSQL7";}
if (indeks==2) {driver ="QODBC3";}
QSqlDatabase *baza = QSqlDatabase::addDatabase ( driver );
baza->setHostName ( hostm );
baza->setDatabaseName ( namem );
baza->setUserName ( userm );
baza->setPassword ( passm );
bool ok = baza->open();
}
To copy to clipboard, switch view to plain text mode
This part definitelly works as I've tested it in many ways.
In another form I'm checking if the connection is properly opened with this code:
void GlavnoO :: pushButton3_clicked()
{
bool ok = FALSE;
ok = povezava.baza->isOpen();
}
void GlavnoO :: pushButton3_clicked()
{
bool ok = FALSE;
ok = povezava.baza->isOpen();
}
To copy to clipboard, switch view to plain text mode
I don't get any errors when compiling. But whet I click on this button I get segmentation fault EVERY time! I've tried it with connection opened and closed. I also did 'make clean' just in case. Nothing worked.
I have no idea how to get past this.
Bookmarks