Quote Originally Posted by jfinn88 View Post
Now that you point it out that makes sense will move open() call inside if() statement, since the if statement is checking for validation would you also pass the instance to QSqlQuery inside the if() block?
No, I would leave the QSqlQuery outside.

Quote Originally Posted by jfinn88 View Post
do I need to close or remove the database?
No, you should be able to keep more than one connection at any given time.


Now I need help fixing my function in my other class

Quote Originally Posted by jfinn88 View Post
Qt Code:
  1. QSqlQuery selectQuery("SELECT id, userName, eventMessage, dateTime FROM userlogevents");
To copy to clipboard, switch view to plain text mode 
You likely want to use the m_selectDataBase for this query, no?

Quote Originally Posted by jfinn88 View Post
Qt Code:
  1. while (selectQuery.next()){
  2. //---Instance of userEventLogMsg Class Struct---//
  3. userEventLogMsg msg;
  4. //---Instance of userEventlog Class---//
  5. UserEventLog model;
  6. //---Add query data to the msg class struct---//
  7. msg.id = selectQuery.value(0).toString();
  8. msg.username = selectQuery.value(1).toString();
  9. msg.eventmessage = selectQuery.value(2).toString();
  10. msg.datetime = selectQuery.value(3).toString();
  11. //---Use model object to access an call addEvent()---//
  12. model.addEvent(msg);
  13. }
To copy to clipboard, switch view to plain text mode 
This doesn't look at all what I assume you want.
This creates a new model instance in every loop iteration, adds one record and then destroys the model (when it goes out of scope).

Cheers,
_