[Qt-interest] QAbstractItemModel data supplied by a different thread.

Brad Howes howes at ll.mit.edu
Wed Jul 28 14:36:10 CEST 2010


On Jul 27, 2010, at 11:51 AM, Justus Best wrote:

> With this in mind I wasn't sure which thread machanism to use. Is it 
> better to call QtConcurrent::run for every image or is it possible, if I 
> create a list with images, to use the Qt::Concurrend::mapped function ? 
> I'm not 100% sure what the mapped function does, if it will only return 
> the list of strings I have passed as they are not getting changed in the 
> function or if a new List with the results of the functions (QPair of 
> QPixmap and int) is created.

A quick look at the QtConcurrent documentation indicates to me that you should go for the QtConcurrent::mappedReduce() method, since you will receive notification via the reduce function parameter when a scaling operation is done, and you can then use it to replace the appropriate place holder image in your display.

Alternatively, you could use mapped() (I think map() as well) along with QFutureWatcher to receive notification when a value in a QFuture sequence is ready for use. That may be the best bet: start scaling a

-- 
Brad Howes
Group 42
MIT Lincoln Laboratory • 244 Wood St. • Lexington, MA 02173
Phone: 781.981.5292 • Fax: 781.981.3495 • Secretary: 781.981.7420









More information about the Qt-interest-old mailing list