I have the following class definition:
#ifndef QMYSQLTABLE_H
#define QMYSQLTABLE_H
#include <QObject>
#include <QSqlQuery>
class QMysqlConnection;
{
Q_OBJECT
friend class QDataLineEdit;
public:
QMysqlTable(const QString& table, const QMysqlConnection* connection,
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
#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
To copy to clipboard, switch view to plain text mode
and the implementation part the function next() is:
bool QMysqlTable::next(void)
{
if (_connection->isValid()) {
emit nextRecord();
}
return false;
}
bool QMysqlTable::next(void)
{
if (_connection->isValid()) {
emit nextRecord();
return QSqlQuery::next();
}
return false;
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks