ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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).
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.