I would look at the lifetime of the "appData" pointer. You are simply storing it in your AutochargeData class. If it goes out of scope (e.g. is deleted) before the AutochargeData class instance does, then it is an invalid pointer and if used will cause a crash.
while (query.next()) {
setOrderID(query.value("increment_id").toString());
setPayment(query.value("method").toString());
setTotal(query.value("grand_total").toString());
}
while (query.next()) {
setOrderID(query.value("increment_id").toString());
setPayment(query.value("method").toString());
setTotal(query.value("grand_total").toString());
}
To copy to clipboard, switch view to plain text mode
This code makes no sense. If the query result has more than one result in it, each time through the loop you are completely replacing the values in your member variables (which themselves should not be public members of the class). At the end of the loop they will simply contain the values from the last result. I don't imagine that is your intent.
Also not really sure why you have derived AutochargeData from QWidget. It doesn't appear to have any user interface, so why? Deriving from QWidget (or QObject for that matter) is unnecessary for pure C++ classes used in a Qt application. If you do derive from a QObject-based class (like QWidget), then you need to include the "Q_OBJECT" macro at the top of the class definition:
{
Q_OBJECT
public:
...
}
class MyClass : public QObject
{
Q_OBJECT
public:
MyClass( QObject * parent );
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks