
Originally Posted by
patcito
here is the test program:
http://p80.free.fr/basicmysql.tar.bz2 could you confirm it doesn't crash for you please? it displays mysql users in a qtableview, you can modify connection.h to change the user password
My idea of a small program is:
#include <QtDebug>
#include <QApplication>
#include <QVariant>
#include "connection.h"
int main(int argc, char *argv[])
{
createConnection();
qDebug() << q.lastError();
while( q.next() ) {
qDebug() << q.value( 0 ) << q.value( 1 );
}
}
#include <QtDebug>
#include <QApplication>
#include <QVariant>
#include "connection.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
createConnection();
QSqlQuery q( "SELECT * FROM user" );
qDebug() << q.lastError();
while( q.next() ) {
qDebug() << q.value( 0 ) << q.value( 1 );
}
}
To copy to clipboard, switch view to plain text mode
Anyway, it seems that there is a bug in Qt 4.1.0. If I change CutePOS::initialize() to:
model->setQuery( "select * from user" );
ui.articlestableView->setModel(model);
QSqlQueryModel *model = new QSqlQueryModel;
model->setQuery( "select * from user" );
ui.articlestableView->setModel(model);
To copy to clipboard, switch view to plain text mode
it works.
Bookmarks