croscato
22nd November 2008, 14:52
I have the following class definition:
#ifndef QMYSQLTABLE_H
#define QMYSQLTABLE_H
#include <QObject>
#include <QSqlQuery>
class QMysqlConnection;
class QMysqlTable: public QObject, protected QSqlQuery
{
Q_OBJECT
friend class QDataLineEdit;
public:
QMysqlTable(const QString& table, const QMysqlConnection* connection,
QObject* = 0);
bool exec(const QString& query);
bool isValid(void) const;
public slots:
bool first(void);
bool previous(void);
bool next(void);
bool last(void);
bool seek(int index, bool relative = false);
signals:
void firstRecord(void);
void previousRecord(void);
void nextRecord(void);
void lastRecord(void);
void seekRecord(void);
private:
const QMysqlConnection* _connection;
const QString& _table;
};
#endif // QMYSQLTABLE_H
and the implementation part the function next() is:
bool QMysqlTable::next(void)
{
if (_connection->isValid()) {
emit nextRecord();
return QSqlQuery::next();
}
return false;
}
the code for the next() function only work if the nextRecord() signal is not emited. Otherwise the program crashes.
What could have been causing this behavior?
Thanks in advance.
#ifndef QMYSQLTABLE_H
#define QMYSQLTABLE_H
#include <QObject>
#include <QSqlQuery>
class QMysqlConnection;
class QMysqlTable: public QObject, protected QSqlQuery
{
Q_OBJECT
friend class QDataLineEdit;
public:
QMysqlTable(const QString& table, const QMysqlConnection* connection,
QObject* = 0);
bool exec(const QString& query);
bool isValid(void) const;
public slots:
bool first(void);
bool previous(void);
bool next(void);
bool last(void);
bool seek(int index, bool relative = false);
signals:
void firstRecord(void);
void previousRecord(void);
void nextRecord(void);
void lastRecord(void);
void seekRecord(void);
private:
const QMysqlConnection* _connection;
const QString& _table;
};
#endif // QMYSQLTABLE_H
and the implementation part the function next() is:
bool QMysqlTable::next(void)
{
if (_connection->isValid()) {
emit nextRecord();
return QSqlQuery::next();
}
return false;
}
the code for the next() function only work if the nextRecord() signal is not emited. Otherwise the program crashes.
What could have been causing this behavior?
Thanks in advance.