PDA

View Full Version : calling Gui treeWidget in Thread class



santosh.kumar
16th May 2007, 05:43
hi
i m not getting correct solution.
I m writing coding like this....


////first class
void DirThread::run()
{
if(!bAbort)
{
showDir();
}
}
void DirThread ::showDir()
{
QTreeWidgetItem *pItem = NULL;
pItem = new QTreeWidgetItem(///treeWidget from Gui class);

showDirView(pItem, strPath);
}
void DirThread ::showDirView(QTreeWidgetItem *pItem,QString strPath)
{
//loop up to size of dir
//Recursivly showing dir
for(///loop)
{
if(//dir)
{
showDirView(//treeItem,//path)
}
else
{
//file show
}
}
}


/////Gui class
GuiClass::GuiClass(QWidget *parent):QDialog(parent)
{
setupUi(this);
treeWidget->setColumnCount(1);
}


///I m using this treeWidget Dialog to show recursivly showing dir view
using thread,,,how i call use treeWidget in Thread Method...
please correct this one...

marcel
16th May 2007, 07:01
The answer is that you don't.
This is like the 10th thread on this issue.

In the worker thread use only QFile, QDir, QFileInfo, etc, and build the directory structure ( you have many choices ). Pass then to the GUI thread the dir structure to the GUI thread and let it update the model.

Or use a QDirModel.

wysota
16th May 2007, 09:14
Please start no more threads on the same subject.