Trolltech Home | QSA-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

QSA-interest Archive, March 2006
passing array to C++ as QVariantList not possible in QSA 1.2.0


Message 1 in thread

Hi
I hope that someone can tell me how to use an script-defined array of strings 
in an custom-QSObject-slot. I read this from Gunnar from the 21 Feb 2006:

> This is sort of possible already... If you create your data as an array 
> you can pass it back to C++ as a QVariantList, but only your indexed 
> data will be available... 

And I tried it in my script using QSA 1.2.0
	var VarNames = [];
	VarNames[0] = "variables0";
	VarNames[1] = "variables1";
	VarNames[2] = "variables2";
	zfsReader.SetMyVars(VarNames);

declaration of zfsReader-SetMyVars()-slot:
	void SetMyVars(QVariantList& varNames);

But I get the following error-message from QSA:
	Error. No matching slot found, available overloads are:
	  void QVSWrapper_vtkZFSReader::SetMyVars(QVariantList&)

Cant I use script-arrays in slots exspecting QVariantList or isnt it possible 
to use slots with references? What can I do? Will this be fixed in QSA 1.2.1?

	Greetings
		Jens 

P.S:
I also tried 
	var VarNames = ["variables0","variables1","variables2"]
in the script and
	QVariantMap&
in my slot. No success.

To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx


Message 2 in thread

If you create your data as an array you can pass it back to C++ as a 
QVariantList BUT NOT als an QVariantList& =>

ok:      void SampleSlot(QVariantList varNames);
error:   void SampleSlot(QVariantList& varNames);

I hope that´s a bug and can get fixed in QSA 1.2.1

	Greetings
		Jens

Am Samstag, 4. März 2006 18:03 schrieb Jens G.:
> Hi
> I hope that someone can tell me how to use an script-defined array of
> strings
>
> in an custom-QSObject-slot. I read this from Gunnar from the 21 Feb 2006:
> > This is sort of possible already... If you create your data as an array
> > you can pass it back to C++ as a QVariantList, but only your indexed
> > data will be available...
>
> And I tried it in my script using QSA 1.2.0
> 	var VarNames = [];
> 	VarNames[0] = "variables0";
> 	VarNames[1] = "variables1";
> 	VarNames[2] = "variables2";
> 	zfsReader.SetMyVars(VarNames);
>
> declaration of zfsReader-SetMyVars()-slot:
> 	void SetMyVars(QVariantList& varNames);
>
> But I get the following error-message from QSA:
> 	Error. No matching slot found, available overloads are:
> 	  void QVSWrapper_vtkZFSReader::SetMyVars(QVariantList&)
>
> Cant I use script-arrays in slots exspecting QVariantList or isnt it
> possible to use slots with references? What can I do? Will this be fixed in
> QSA 1.2.1?
>
> 	Greetings
> 		Jens
>
> P.S:
> I also tried
> 	var VarNames = ["variables0","variables1","variables2"]
> in the script and
> 	QVariantMap&
> in my slot. No success.
>
> To unsubscribe - send "unsubscribe" in the subject to
> qsa-interest-request@xxxxxxxxxxxxx

To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx


Message 3 in thread

Jens,

> ok:      void SampleSlot(QVariantList varNames);
> error:   void SampleSlot(QVariantList& varNames);

I think in general you should not use pass-by-reference anyway.   
Particularly non-const as in your example.  That would indicate that  
the C++ function is going to modify the argument passed in, which  
pretty much violates the semantics of the QSA language, and might not  
even work at all.  (It would be better to return another QVariantList  
that has been modified, if you are in fact intending to modify the  
argument.)  If you're going to use a const reference as an argument,  
I think that would work, but you could also just as well pass by  
value, since the Qt container classes all implement shallow copying.

So, I don't believe this is a bug in QSA.

Joel Nordell
Software Engineer
ONEAC Corp.


On Mar 4, 2006, at 11:20 AM, Jens G. wrote:

> If you create your data as an array you can pass it back to C++ as a
> QVariantList BUT NOT als an QVariantList& =>
>
> ok:      void SampleSlot(QVariantList varNames);
> error:   void SampleSlot(QVariantList& varNames);
>
> I hope that´s a bug and can get fixed in QSA 1.2.1
>
> 	Greetings
> 		Jens
>
> Am Samstag, 4. März 2006 18:03 schrieb Jens G.:
>> Hi
>> I hope that someone can tell me how to use an script-defined array of
>> strings
>>
>> in an custom-QSObject-slot. I read this from Gunnar from the 21  
>> Feb 2006:
>>> This is sort of possible already... If you create your data as an  
>>> array
>>> you can pass it back to C++ as a QVariantList, but only your indexed
>>> data will be available...
>>
>> And I tried it in my script using QSA 1.2.0
>> 	var VarNames = [];
>> 	VarNames[0] = "variables0";
>> 	VarNames[1] = "variables1";
>> 	VarNames[2] = "variables2";
>> 	zfsReader.SetMyVars(VarNames);
>>
>> declaration of zfsReader-SetMyVars()-slot:
>> 	void SetMyVars(QVariantList& varNames);
>>
>> But I get the following error-message from QSA:
>> 	Error. No matching slot found, available overloads are:
>> 	  void QVSWrapper_vtkZFSReader::SetMyVars(QVariantList&)
>>
>> Cant I use script-arrays in slots exspecting QVariantList or isnt it
>> possible to use slots with references? What can I do? Will this be  
>> fixed in
>> QSA 1.2.1?
>>
>> 	Greetings
>> 		Jens
>>
>> P.S:
>> I also tried
>> 	var VarNames = ["variables0","variables1","variables2"]
>> in the script and
>> 	QVariantMap&
>> in my slot. No success.
>>
>> To unsubscribe - send "unsubscribe" in the subject to
>> qsa-interest-request@xxxxxxxxxxxxx
>
> To unsubscribe - send "unsubscribe" in the subject to qsa-interest- 
> request@xxxxxxxxxxxxx

To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx