Qt 101: Why can't I use this class?
Posted
by Airjoe
on Stack Overflow
See other posts from Stack Overflow
or by Airjoe
Published on 2010-06-10T03:20:24Z
Indexed on
2010/06/10
3:22 UTC
Read the original article
Hit count: 280
I have experience with C++ but I've never really used Qt before. I'm trying to connect to a SQLite database, so I found a tutorial here and am going with that. In the QtCreator IDE, I went to Add New --> C++ Class and in the header file pasted in the header the header from that link and in the .cpp file I pasted the source. My main.cpp looks like this:
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "databasemanager.h"
#include <qlabel.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
DatabaseManager db();
QLabel hello("nothing...");
if(db.openDB()){
hello.setText("Win!");
}
else{
hello.setText("Lame!");
}
hello.resize(100, 30);
hello.show();
return a.exec();
}
And I'm getting this error:
main.cpp:13: error: request for member 'openDB' in 'db', which is of non-class type 'DatabaseManager()'
Can anyone point me in the right direction? I know "copypaste" code isn't good, I just wanted to see if I could get DB connectivity working and I figured something like this would be simple... thanks for the help.
© Stack Overflow or respective owner