1. read this: You’re doing it wrong…
I don't think that i use QThread incorrectly and you can see the followinf function
void SearchEngine
::search(QStringList aSearchWord, QList<int>aBooksIds
) {
m_searchWord = aSearchWord;
m_booksIds = aBooksIds;
if(!isRunning())
{
start();
}
}
void SearchEngine::search(QStringList aSearchWord, QList<int>aBooksIds)
{
m_searchWord = aSearchWord;
m_booksIds = aBooksIds;
if(!isRunning())
{
start();
}
}
To copy to clipboard, switch view to plain text mode
i just use the search function to init some variables and also to start the thread.
2. when connections between threads are made, then when signal is emitted event is send to another thread. So code which receives signals from another thread have to process event loop. So every time you are expecting signal to be received you have to call QCoreApplication:

rocessEvents or QTest::qWait(200) (I recommend qWait since it may require to wait for this event).
i did just as you saied but still the slot never been called and here are the code the used
void TestSearchEngine::testSearch()
{
searchWords << tr("ظ…ط*ظ…ط¯");
QList<int> booksId;
booksId << 11430;
m_pSearchEngine->search(searchWords, booksId);
}
void TestSearchEngine::testSearch()
{
QStringList searchWords;
searchWords << tr("ظ…ط*ظ…ط¯");
QList<int> booksId;
booksId << 11430;
m_pSearchEngine->search(searchWords, booksId);
QCoreApplication::processEvents();
}
To copy to clipboard, switch view to plain text mode
Bookmarks