Spent all day Friday and today looking at examples and can't spot what I'm doing wrong. Based on the error I feel like it's got to be something fundamental. I've reproduced the error below.
#include <QtCore/QCoreApplication>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QDir>
#include <QFile>
#include <QDebug>
int main(int argc, char *argv[])
{
bool ret=false;
strDBFile.
append(QDir::separator()).
append("my.db.sqlite");
strDBFile
= QDir::toNativeSeparators(strDBFile
);
db.setDatabaseName(strDBFile);
if(db.isOpen())
{
ret=q.exec("create table WTF(ID INT, NAME VARCHAR(20))");
if(ret)
{
ret=q.exec("insert into WTF values(1, 'your mom')");
if(ret)
{
q.exec("select * from WTF;");
if(q.next())
{
qDebug()<<q.value(0).toString();
}
}
}
}
return a.exec();
}
#include <QtCore/QCoreApplication>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QDir>
#include <QFile>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSqlQuery q;
bool ret=false;
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
QString strDBFile(QDir::home().path());
strDBFile.append(QDir::separator()).append("my.db.sqlite");
strDBFile = QDir::toNativeSeparators(strDBFile);
db.setDatabaseName(strDBFile);
if(db.isOpen())
{
ret=q.exec("create table WTF(ID INT, NAME VARCHAR(20))");
if(ret)
{
ret=q.exec("insert into WTF values(1, 'your mom')");
if(ret)
{
q.exec("select * from WTF;");
if(q.next())
{
qDebug()<<q.value(0).toString();
}
}
}
}
return a.exec();
}
To copy to clipboard, switch view to plain text mode
C:/Documents and Settings/ald/My Documents/SQLStub/SQLStub-build-desktop/../SQLStub/main.cpp:36: error: invalid use of incomplete type 'struct QVariant'
c:\Qt\2010.04\qt\include/QtCore/../../src/corelib/kernel/qobject.h:66: error: forward declaration of 'struct QVariant'
C:/Documents and Settings/ald/My Documents/SQLStub/SQLStub-build-desktop/../SQLStub/main.cpp:36: error: invalid use of incomplete type 'struct QVariant'
c:\Qt\2010.04\qt\include/QtCore/../../src/corelib/kernel/qobject.h:66: error: forward declaration of 'struct QVariant'
To copy to clipboard, switch view to plain text mode
Bookmarks