Okay. So here is my revised code. Is this okay?

QueryView.hpp:

Qt Code:
To copy to clipboard, switch view to plain text mode 

QueryView.cpp:

Qt Code:
  1. QueryView::QueryView()
  2. {
  3. connect(SignalClass.get(),SIGNAL(updateViewSignal(QueryTerm&)), this, SLOT(updateView(QueryTerm&)));
  4. connect(queryButton, SIGNAL(clicked()),this, SLOT(doQuery()));
  5. }
  6.  
  7. void QueryView::doQuery()
  8. {
  9. t = new QThread()
  10. emit fSignalClass->stopExistingQuery();
  11. std::shared_ptr<QueryAction> action = std::make_shared<QueryAction>(queryTerm);
  12. action->moveToThread(t);
  13. t->start();
  14. emit fSignalClass->excuteSignal();
  15.  
  16. }
  17.  
  18. QueryView::updateView(QueryTerm& term)
  19. {
  20. ...update view with query result
  21. }
To copy to clipboard, switch view to plain text mode 

QueryAction class:

Qt Code:
  1. QueryAction::QueryAction(QueryTerm& queryTerm): fQueryTerm(queryTerm)
  2. {
  3. connect(SignalClass.get(), SIGNAL(excuteSignal()), this, SLOT(startSearch()));
  4. connect(SignalClass.get(), SIGNAL(stopExistingQuery()), this, SLOT(stopQuery()));
  5. continueQuery = true;
  6. }
  7.  
  8. void QueryAction::startSearch()
  9. {
  10. //init cursor
  11. while (db_cursor != empty)
  12. {
  13. ...get query result
  14. if (continueQuery)
  15. emit fSignalClass->updateViewSignal(aResult);
  16. }
  17. }
  18.  
  19. void QueryAction::stopQuery()
  20. {
  21. continueQuery = false;
  22. }
To copy to clipboard, switch view to plain text mode