青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品


Say hello to QtScript! 
Posted by Kent on Friday, January 05, 2007 @ 09:25

QtScript is a new module that will be introduced in the next minor release of Qt (4.3). It is a scripting environment that you embed in your C++ Qt application. While the release of Qt 4.3 is still a few months away, fortunately QtScript has just recently been integrated into the daily Qt snapshots, so you can start playing with it now. All you need to do is add

QT += script

to your .pro file, and

#include

in your source file(s), and you’re ready to rock.

QtScript conforms to the ECMA-262 ECMAScript scripting language standard, the core language that’s the basis of JavaScript and Flash ActionScript (to name two well-known languages). The key ECMAScript extension provided by QtScript is the QObject extension; QtScript leverages the introspection capabilities of the Qt Meta-Object System to provide dynamic bindings of the signals and slots and properties of Qt objects (QObject and subclasses thereof).

To give you an idea of what it looks like, here’s a small example showing how to register a widget in the scripting environment, and then manipulate it in script code:

#include
#include
#include 
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton button;

QScriptEngine engine;
QScriptValue scriptButton = engine.scriptValueFromQObject(&button);
engine.globalObject().setProperty(”button”, scriptButton);
engine.evaluate(”button.text = ‘Hello World!’”);
engine.evaluate(”button.styleSheet = ‘font-style: italic’”);
engine.evaluate(”button.show()”);

return app.exec();
}

In script code, you can connect to signals of a Qt object. The target of the connection can either be a Qt slot, or a script function. Example of the latter:

function onButtonClicked(checked) {
print ("button was checked:", checked);
print ("button text:", this.text);
}
button.clicked.connect(onButtonClicked);

As you can see, the sender() of the signal is available as the this object in the script function. You can also use array-style member access:

button['toggled(bool)'].connect(app.quit);

You can disconnect from the signal again like so:

button.clicked.disconnect(onButtonClicked);

If you’re never going to explicitly disconnect from the signal again, the target function can be anonymous:

button.clicked.connect(
function (checked) {
print ("button was checked:", checked);
print ("button text:", this.text);
}
}

Child objects are accessible as members too, so long as the child has its objectName set. A natural application of this feature is when building user interfaces at runtime: Use QUiLoader to build the form, then manipulate the form from script code:

form.buttonBox.accepted.connect(/* some function */)
form.buttonBox.rejected.connect(/* some function */)
form.userNameEdit.text = "Ned Flanders";
form.exec();

There’s more interesting stuff you can do, such as registering your own functions for value conversion (marshalling), binding C++ functions (not just slots), and making slots “script-aware” (using a class called QScriptable). See the QtScript docs in the snapshots for more information.

And finally, some quick questions and answers:

Q: What about QSA?
A: For those of you familiar with QSA (Qt Script for Applications): The new QtScript module bears no relation to QSA. The API is new and the implementation is new. QSA will reach the end of its lifetime in 2008. We’re not touting QtScript as a “QSA replacement” per se, but QtScript clearly offers a lot of the same functionality as QSA, and will naturally offer even more in the future. Just don’t expect to be able to port your existing QSA projects to QtScript in under an hour; as already stated, QSA and QtScript are similar in concept, but very different in practice.

Q: What about performance?
A: QtScript offers far better performance than, say, QSA (by a couple of orders of magnitude). The performance is comparable to SpiderMonkey in most areas.

Q: What about bindings for the rest of Qt?
A: The emphasis is not on bindings for the 4.3 release, but rather on the core scripting environment; e.g. interpreter, ECMAScript compliance, QObject bindings. We offer an API you can use for writing your own bindings, in case the QObject bindings are not sufficient. Don’t expect to be able to write entire applications in only QtScript, at least not with the first release.

Well, have fun and let us know what you think. Remember, there’s still time for us to take your thoughts into account before the first official QtScript release.

posted on 2007-10-07 00:17 清源游民 閱讀(3302) 評論(3)  編輯 收藏 引用 所屬分類: Qt

FeedBack:
# re: Say hello to QtScript!(轉)
2007-10-07 06:57 | Minidx全文檢索
唉……  回復  更多評論
  
# re: Say hello to QtScript!(轉)[未登錄]
2007-11-20 14:04 | fred
engine.scriptValueFromQObject(&button);

QScriptEngine 里沒有scriptValueFromQObject這個函數啊


不知道大俠用的是什么版本的  回復  更多評論
  
# re: Say hello to QtScript!(轉)[未登錄]
2007-11-20 14:58 | fred
QPushButton button;

QScriptEngine engine;
QScriptValue scriptButton = engine.newQObject( &button);
engine.globalObject().setProperty("button", scriptButton);
engine.evaluate("button.text = 'Hello World!'");
engine.evaluate("button.styleSheet = 'font-style: italic'");
engine.evaluate("button.show()");  回復  更多評論
  
<2009年5月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

留言簿(35)

隨筆分類(78)

隨筆檔案(74)

文章檔案(5)

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲午夜久久久久久久久电影院| 欧美在线视频在线播放完整版免费观看 | 亚洲午夜激情| 亚洲韩国一区二区三区| 久久婷婷成人综合色| 久久夜色精品国产噜噜av| 欧美成ee人免费视频| 亚洲成色777777女色窝| 亚洲国产综合视频在线观看| 亚洲毛片在线免费观看| 亚洲男女毛片无遮挡| 久久一区二区三区超碰国产精品| 欧美凹凸一区二区三区视频| 欧美日韩第一页| 国产日本欧美一区二区| 亚洲黄页视频免费观看| 欧美激情a∨在线视频播放| 一区二区三区中文在线观看| 亚洲国产合集| 亚洲与欧洲av电影| 欧美影院视频| 欧美电影免费观看高清完整版| 亚洲欧洲日本mm| 午夜在线不卡| 欧美日韩二区三区| 精品动漫3d一区二区三区免费| 亚洲理论在线观看| 久久精品亚洲| 日韩午夜高潮| 免费在线亚洲| 国内精品99| 亚洲欧美另类国产| 欧美激情一区在线| 欧美一级成年大片在线观看| 欧美伦理91i| 最新日韩在线| 免费在线观看日韩欧美| 亚洲在线成人| 欧美日韩中文| 日韩视频在线观看免费| 美国成人毛片| 欧美一区二区三区免费视频| 欧美午夜精品电影| 亚洲精品免费网站| 免播放器亚洲| 久久99伊人| 欧美午夜精品久久久久久超碰| 最新中文字幕一区二区三区| 午夜久久资源| 亚洲美女av网站| 欧美激情综合五月色丁香| 国产亚洲综合性久久久影院| 香蕉久久精品日日躁夜夜躁| 亚洲精品在线视频观看| 久久这里只有精品视频首页| 国产一区在线播放| 香蕉亚洲视频| 亚洲影音一区| 欧美区亚洲区| 亚洲久久一区| 日韩视频专区| 欧美激情在线观看| 亚洲国产美女| 美女露胸一区二区三区| 亚洲欧美日韩另类| 国产一区激情| 麻豆精品传媒视频| 久久精品国产一区二区三区| 狠狠色狠狠色综合| 久久久久久久久久看片| 午夜精品福利一区二区蜜股av| 欧美日韩情趣电影| 一区二区三区导航| 亚洲精品国产拍免费91在线| 欧美日韩亚洲激情| 欧美在线亚洲在线| 久久久99爱| 久久全国免费视频| 亚洲电影av| 久久婷婷av| 美国成人直播| 亚洲日韩欧美视频一区| 一区二区激情视频| 国产一区视频在线看| 亚洲第一精品电影| 欧美视频官网| 久久婷婷成人综合色| 欧美成人资源网| 亚洲欧美日韩国产综合在线 | 欧美激情成人在线视频| 一区二区三区成人精品| 亚洲女同在线| 91久久综合| 亚洲男人av电影| 91久久久国产精品| 亚洲一区免费网站| 亚洲国产精品激情在线观看| 99国产精品国产精品毛片| 国产午夜久久| 99亚洲伊人久久精品影院红桃| 国产日韩欧美在线播放| 亚洲激情视频在线| 国产一区二区三区在线免费观看 | 久久成人精品| 欧美—级在线免费片| 久久精品中文| 欧美日韩亚洲一区二区三区在线观看| 久久久999成人| 国产精品久久国产精麻豆99网站| 免费一区二区三区| 国产视频一区在线观看| 亚洲卡通欧美制服中文| 狠色狠色综合久久| 亚洲一区网站| 一区二区三区不卡视频在线观看| 久久久欧美精品sm网站| 欧美专区中文字幕| 欧美日韩国产不卡在线看| 快she精品国产999| 国产亚洲毛片在线| 亚洲私人影院| 亚洲免费在线播放| 欧美日韩卡一卡二| 欧美激情一区二区三区全黄| 韩国成人福利片在线播放| 亚洲女人天堂av| 亚洲无线一线二线三线区别av| 欧美高潮视频| 亚洲第一毛片| 亚洲国产欧美日韩| 午夜精品www| 性久久久久久久久| 国产精品一级| 亚洲一区欧美一区| 亚洲精品自在久久| 亚洲国产欧美在线人成| 欧美精品日韩一区| 欧美激情在线有限公司| 一区二区视频在线观看| 久久精品天堂| 久久永久免费| 在线观看欧美视频| 久久综合久久久久88| 欧美大片免费观看| 亚洲激情影视| 欧美日韩国产综合久久| 9久re热视频在线精品| 亚洲一区二区三区免费视频| 欧美四级电影网站| 亚洲一区二区三区777| 欧美一区二区在线免费播放| 国产一区二区三区最好精华液| 欧美在线视频全部完| 美女图片一区二区| 亚洲三级观看| 欧美日韩国产系列| 亚洲一区二区三区涩| 久久精品视频播放| 亚洲黑丝在线| 欧美视频一区二区在线观看 | 欧美日韩视频不卡| 亚洲欧美日本在线| 久久综合色8888| 亚洲理伦电影| 国产日韩欧美制服另类| 久久精品夜色噜噜亚洲aⅴ| 欧美韩日一区二区三区| 亚洲视频一区二区| 狠狠色综合网站久久久久久久| 你懂的成人av| 亚洲男人第一av网站| 欧美激情在线免费观看| 午夜精品一区二区三区在线播放 | 亚洲精品国产无天堂网2021| 欧美日韩亚洲国产精品| 久久精品国产亚洲aⅴ| 亚洲精品欧美日韩| 久久精品国产在热久久| 亚洲精品乱码久久久久久蜜桃麻豆| 国产精品爱啪在线线免费观看| 久久国产精品久久久久久电车| 亚洲人成免费| 久久久久久亚洲综合影院红桃| 9人人澡人人爽人人精品| 国产一区二区欧美日韩| 欧美日韩成人激情| 久久一日本道色综合久久| 亚洲视频免费在线| 91久久中文| 久久人人97超碰国产公开结果| 一区二区激情视频| 亚洲国产婷婷| 一区二区在线观看av| 国产精品婷婷| 欧美精品成人一区二区在线观看| 欧美一区二区三区四区高清| 一本色道久久综合亚洲二区三区| 亚洲高清资源| 免费成人在线观看视频| 欧美一区二粉嫩精品国产一线天|