Interoperability between QT and flash

Source: Internet
Author: User

I have been studying Action Script in the past few days. I found the possibility of interoperability between QT and flash on the Internet. I tried it and succeeded.

First, QT calls functions in flash:

Qaxwidget.swf file code is as follows:

Qaxwidget flash (this, null );
Flash. setcontrol (qstring: fromutf8 ("{d27cdb6e-ae6d-11cf-96b8-444553540000 }"));
Flash. dynamiccall ("loadmovie (long, string)", 0, "E: // first.swf ");

How to call the method in flash, first use the externalinterface. addcall method in flash to add access points for external interaction:

Externalinterface. addcallback ("drawcircleexternal", drawcircle );

Then how to call this function in QT. In my as3 code, drawcircle needs an int-type parameter, so the call code is as follows:

 

Qstring STR;

Qtextstream (& Str) <""

<""

<"" <""

<""

<"";

Flash. dynamiccall ("callfunction (string)", STR );

Here, returntype must be XML, and the return value of drawcircle cannot be obtained. I don't know why, but this is not very important.

How to call C ++ in as3 is still implemented through the call method in the externalinterface class in as3.

The code for as3 is as follows:

Externalinterface. Call ("calcu", "bbcc ");

Calcu is the external function name and "bbcc" is the parameter.

When this code is executed in as3, qaxwidget generates a signal in the following format:

Flashcall (qstring)

The content of qstring is as follows:

Bbcc

Therefore, to call C ++ through as3 in QT, you must write a slot and associate it with the above signal. The specific code is as follows:

Connect (& flash, signal (flashcall (qstring), this, slot (calcu (const qstring &)));

Put the code to be called into calcu. Of course, the slot name is not necessarily the same as the function name in as3. you can change it at will.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/liurenjie2008/archive/2010/03/29/5430183.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.