LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-23-2008, 08:33 AM   #1
sydney-troz
Member
 
Registered: Feb 2007
Distribution: Kubuntu, it's obese barely-usable sibling, Ubuntu
Posts: 142

Rep: Reputation: 15
Qt 4: Returning a QFuture with multiple items


Hi

Does anyone know if it's possible to somehow use the Qt 4 threading API to return a custom QFuture? My scenario is this: I have a GUI that displays a couple of lists of strings, but the code that generates the lists involves multiple hard-drive reads, some processing, etc., so the GUI tends to lag a bit during list generation.

The only custom feature that I've been able to find is QtConcurrent::run(), which just wraps a normal return type in a single-item QFuture. I'd like to be able to return the items of the list as they are generated, but I can't seem to find any documentation on doing so (Google, this forum, Qt 4 docs).

Thanks,
Syd
 
Old 08-23-2008, 07:07 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
I've never used QFuture (guess I need to upgrade from 4.3.5...) In the past the way I have tackled your problem (if I understand it correctly) is by running a thread for the computation and then emit'ing a signal periodically. You need to connect the signal you will emit to a method that in your case will update the GUI list before starting the computation.

This should work from within a QFuture object
 
Old 08-23-2008, 07:48 PM   #3
sydney-troz
Member
 
Registered: Feb 2007
Distribution: Kubuntu, it's obese barely-usable sibling, Ubuntu
Posts: 142

Original Poster
Rep: Reputation: 15
I tried that, but the types I was passing around weren't QObjects or integral types, so short of wrapping them in special classes, that didn't work. However, I was looking at the Qt source, and the undocumented QFutureInterface class gives me all the functionality I was looking for. Not sure how good of an idea it is to be using such a class, and I haven't tested it yet, but it looks like it should work beatifully. Unfortunately, I'm left to figure out it's behaviour on my own.
 
  


Reply

Tags
qt



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++: need helping searching for multiple items in a string BrianK Programming 20 02-21-2008 02:59 PM
Multiple Autologins; Multiple Users; Multiple Sessions mrclisdue Linux - Desktop 1 09-26-2007 05:50 AM
CTRL+click, SHIFT+click no longer selecting multiple items General Linux - Hardware 1 05-20-2007 03:11 PM
ld returning 1 angelo_maci Linux - Software 1 04-10-2006 01:41 PM
mvoing multiple items gonus Linux - General 2 01-20-2003 07:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration