PDA

View Full Version : QThread?



vishal.chauhan
23rd March 2007, 11:09
Hi All,

I m using QT 4.2.2 on my Intel Mac.

I have some code in which I make making a tree of Dir and file.
I select a Path and then add the Item in tree Structure in QTreeWidget as I have File under dir and the Tree Structure is as file and dir stored on my Hard Disk.


Now If there are Lots of File and Dir then the Application is taking a lot of time to add them and Its Looking like the Application is get hanged for a time Period.

Now I want to this thing by Using thread and I donot know how to use the Thread?

If any one Knows then plz Help.

Thanks.

high_flyer
23rd March 2007, 11:21
Now I want to this thing by Using thread and I donot know how to use the Thread?
You will have to start by reading the docs.
Then if you have specific questions, feel free to ask.

But I am not sure a thread is a good solution to your problem.
If the only thing you want to acheave is to have the GUI responsive while waiting for some operation to finish, you can just show a progress bar.
This way the user will konw that the application has not hang up, and he will know in which state of progrees the operation is.
A thread makes sense only when you want to allow the user to do something else while this operation is taking place.

fullmetalcoder
23rd March 2007, 18:39
I have some code in which I make making a tree of Dir and file.
I select a Path and then add the Item in tree Structure in QTreeWidget as I have File under dir and the Tree Structure is as file and dir stored on my Hard Disk.

Now If there are Lots of File and Dir then the Application is taking a lot of time to add them and Its Looking like the Application is get hanged for a time Period.

I think you got a design problem here. Or at least room for huge improvements... Convinience views such as QTreeView (http://doc.trolltech.com/latest/qtreeview.html) and QListView (http://doc.trolltech.com/latest/qlistview.html) are not suited for display of many items (when many gets to many...;)) especially when :
the item are added one by one
the view is visible while adding itemsThe best way here would probably be to fill a model with proper data and then display it in a view. Bonus hint : QDirModel (http://doc.trolltech.com/latest/qdirmodel.html) should do very well as far as you're concerned... :)

vishal.chauhan
26th March 2007, 13:37
You will have to start by reading the docs.


Where will I get the document Related to that.
I want simple Examples of Qt of Threads to start with if U know Where I can get then then plz help me Out.

Thanks.

jpn
26th March 2007, 13:43
Where will I get the document Related to that.
I want simple Examples of Qt of Threads to start with if U know Where I can get then then plz help me Out.

Thread Support in Qt (http://doc.trolltech.com/4.2/threads.html)
QThread
Thread Examples (http://doc.trolltech.com/4.2/examples.html#thread-examples)