Sorry guys for the late reply. I did as you said, moved all signals and slots to respective classes instead of relying on Signal Class as I was doing. Still the same performance, app hangs badly, the loading symbol completely freezes, but after some time all query results do show up on the UI. Here is my code:
QueryView.hpp:
class QueryView
{
QueryAction *action;
signals:
void excuteSignal();
void stopExistingQuery();
}
class QueryView
{
QThread *t;
QueryAction *action;
signals:
void excuteSignal();
void stopExistingQuery();
}
To copy to clipboard, switch view to plain text mode
QueryView.cpp:
QueryView::QueryView()
{
connect(SignalClass.get(),SIGNAL(updateViewSignal(QueryTerm&)), this, SLOT(updateView(QueryTerm&)));
connect(queryButton, SIGNAL(clicked()),this, SLOT(doQuery()));
}
void QueryView::doQuery()
{
emit stopExistingQuery();
action = new QueryAction(queryTerm);
connect(this,SIGNAL(excuteSignal()), fSearchAction, SLOT(startQuery()));
connect(this,SIGNAL(stopExistingQuery()), fSearchAction, SLOT(stopQuery()));
connect(fSearchAction,
SIGNAL(updateViewSignal
(QString)),
this,
SLOT(updateView
(QString)));
action->moveToThread(t);
t->start();
emit excuteSignal();
}
QueryView::updateView(QString& term)
{
...
update view with query result, currently a string
for testing purpose, as a
QPushButton, forming a series of buttons in a
QTableWidget}
QueryView::QueryView()
{
connect(SignalClass.get(),SIGNAL(updateViewSignal(QueryTerm&)), this, SLOT(updateView(QueryTerm&)));
connect(queryButton, SIGNAL(clicked()),this, SLOT(doQuery()));
}
void QueryView::doQuery()
{
t = new QThread()
emit stopExistingQuery();
action = new QueryAction(queryTerm);
connect(this,SIGNAL(excuteSignal()), fSearchAction, SLOT(startQuery()));
connect(this,SIGNAL(stopExistingQuery()), fSearchAction, SLOT(stopQuery()));
connect(fSearchAction, SIGNAL(updateViewSignal(QString)),this, SLOT(updateView(QString)));
action->moveToThread(t);
t->start();
emit excuteSignal();
}
QueryView::updateView(QString& term)
{
...update view with query result, currently a string for testing purpose, as a QPushButton, forming a series of buttons in a QTableWidget
}
To copy to clipboard, switch view to plain text mode
QueryAction.hpp:
class QueryAction
{
signals:
}
class QueryAction
{
QMutex m_mutex;
signals:
void updateSearchView2(QString);
}
To copy to clipboard, switch view to plain text mode
QueryAction.cpp:
QueryAction::QueryAction(QueryTerm& queryTerm): fQueryTerm(queryTerm)
{
continueQuery = true;
}
void QueryAction::startSearch()
{
//init cursor
while (db_cursor != empty)
{
...get query result
if (continueQuery)
emit updateViewSignal(aResult.asQString());
else
break;
}
}
void QueryAction::stopQuery()
{
continueQuery = false;
}
QueryAction::QueryAction(QueryTerm& queryTerm): fQueryTerm(queryTerm)
{
QMutexLocker locker(&m_mutex);
continueQuery = true;
}
void QueryAction::startSearch()
{
//init cursor
while (db_cursor != empty)
{
...get query result
QMutexLocker locker(&m_mutex);
if (continueQuery)
emit updateViewSignal(aResult.asQString());
else
break;
}
}
void QueryAction::stopQuery()
{
QMutexLocker locker(&m_mutex);
continueQuery = false;
}
To copy to clipboard, switch view to plain text mode
Bookmarks