Your problem is that on line 32, you declare another instance of your variable "db", which hides the one you declare as a member variable of your class. As soon as conOpen() ends, this instance of "db" goes out of scope and is destroyed. Your member variable "db" is never initialized to anything.
To fix it, simply remove the word "QSqlDatabase" from line 32.
Bookmarks