I'm not sure about the need to subclass anything, but you're right,
initializing the mapFunctor variable definitely helps ;)

So I got everything working new, except I cannot set the returned
QFutureVoid to the QFutureWatcher because it expects a QFuture object (and
it can't be typecast)

*Set<String> set = new HashSet();*
*QFutureWatcher futureWatcher = new QFutureWatcher();
QtConcurrent.MapFunctor<String> mapFunctor = new
QtConcurrent.MapFunctor<String>() {
        @Override
        public void map(String t) {
            System.out.println("Thread: + t);
        }
*
*QFutureVoid future = QtConcurrent.map(set, mapFunctor);*

*futureWatcher.setFuture(future);* << not possible since the type is
incorrect.

The weird thing is, that in the ProgressbarDialog example in the official
Qt docs, this appears to be possible.

There's also QtConcurrent.mapped(), which returns a QFuture I should be
able to use, but it then requires an additional parameter and I don't know
what it expects really.

Regards

Ralf





On Mon, Aug 20, 2012 at 6:42 PM, Darryl Miles <
darryl-mailingli...@netbauds.net> wrote:

>
>
>  *However executing this returns the following error file each string in
>> the set;
>>
>> /Map functor called with invalid data. JNI Environment == 0x994e520,
>> java functor object == 0x0/
>>
>>
>> I haven't got experience with java functors, from what I gather they're
>> like callback functions right?
>>
>
> Yes they are a particular pattern for providing callbacks by encapsulating
> the callback as an object (this allows for variables to exist that have
> scope with the functor object class and reuse/sharing of the resulting
> callable handle my multiple users).
>
> With a functor the result would have and be a type in their own right in a
> namespace somewhere.
>
> A lambda can be thought of an an anonymous/nameless functor.  A benefit
> with lambda (looking towards Java8) is the ability to describe them on the
> fly out of new Java language syntax without there needing to be a concrete
> class or interface to based it on.
>
> Which is currently the case for Java anonymous classes you need to
> describe a named interface first in order to base (subclass) your anonymous
> class on.
>
>
>
>  Can you help me fix this?
>>
>
> Well of course the variable "mapFunctor" is null in the code you provided.
>  It is never assigned any value.
>
>
> Maybe lookup the C++ API and find the type used as mapFunctor then search
> QtJambi classes for it and create a custom (subclassed) instance.
>
> Darryl
>
>
_______________________________________________
Qt-jambi-interest mailing list
Qt-jambi-interest@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-jambi-interest

Reply via email to