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


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>
            正在播放日韩| 久久精品99国产精品日本 | 亚洲一区二区三区成人在线视频精品| 欧美中文字幕视频在线观看| 欧美日韩国产色视频| 亚洲国产综合在线| 欧美ed2k| 久久亚洲捆绑美女| 亚洲福利视频专区| 麻豆久久精品| 久久人人九九| 亚洲国产导航| 亚洲高清视频在线| 久久最新视频| 亚洲国产精品一区二区第四页av| 麻豆精品视频在线观看视频| 久久久99久久精品女同性| 黄色日韩网站视频| 欧美不卡一卡二卡免费版| 免费观看成人www动漫视频| 亚洲国产午夜| 亚洲免费av网站| 国产精品v欧美精品v日韩精品| 亚洲一区美女视频在线观看免费| 中文在线不卡| 国产欧美日韩一区二区三区在线观看| 欧美一区二区精品| 性欧美18~19sex高清播放| 国产一区激情| 欧美激情1区2区| 欧美区国产区| 欧美一区激情| 久久视频一区| 中文国产成人精品| 亚洲欧美国产精品专区久久| 国产在线播放一区二区三区| 美女久久一区| 欧美精品18| 欧美在线www| 美脚丝袜一区二区三区在线观看| 国产精品99久久久久久宅男| 午夜精品视频在线| 亚洲国产精品久久| 亚洲一区二区精品视频| 揄拍成人国产精品视频| 亚洲久久视频| 国产亚洲精品综合一区91| 欧美国产综合视频| 国产精品久久二区二区| 久久久久成人精品| 欧美精品在线一区| 久久婷婷国产麻豆91天堂| 欧美激情亚洲另类| 久久人人爽人人爽| 欧美日韩一二三四五区| 久久嫩草精品久久久精品| 欧美激情国产高清| 久久久综合免费视频| 欧美三级精品| 欧美成人高清视频| 国产情侣久久| 一本色道久久综合亚洲91| 狠狠色伊人亚洲综合成人| 中文在线一区| 亚洲免费av片| 久久久一二三| 久久精品视频在线看| 欧美日韩三级在线| 亚洲国产精品久久久久秋霞影院 | 一区二区三区蜜桃网| 久久精品国产2020观看福利| 亚洲一级二级| 免费一级欧美片在线播放| 久久av最新网址| 欧美亚男人的天堂| 亚洲黄色视屏| 亚洲第一精品夜夜躁人人爽| 亚洲欧美激情一区二区| 一本色道久久88综合日韩精品| 久久久久久久久久久久久女国产乱| 亚洲欧美一区二区原创| 欧美日韩精品三区| 亚洲国产欧美在线人成| 尤物yw午夜国产精品视频| 午夜精彩国产免费不卡不顿大片| 一本色道久久| 欧美日韩伊人| 亚洲精选国产| 一区电影在线观看| 欧美日韩国产在线一区| 亚洲毛片在线观看.| 中文亚洲欧美| 国产精品第一区| 一卡二卡3卡四卡高清精品视频| 亚洲精品视频在线观看免费| 蜜月aⅴ免费一区二区三区| 欧美激情亚洲精品| 亚洲精品少妇| 欧美精品激情在线观看| 亚洲黑丝在线| 一本久久综合亚洲鲁鲁五月天 | 亚洲欧美日韩国产中文| 欧美日韩综合一区| 亚洲一级在线观看| 久久精品国产精品亚洲综合| 国产日韩亚洲欧美精品| 久久精品盗摄| 亚洲风情亚aⅴ在线发布| 99国产精品久久| 欧美日韩三区四区| 亚洲一区二区三区在线看| 久久福利影视| 亚洲第一网站| 欧美伦理视频网站| 一区二区三区欧美亚洲| 久久成人一区| 亚洲国产精品久久久久秋霞不卡| 欧美电影在线观看完整版| 99在线精品视频在线观看| 欧美在线视频免费观看| 日韩视频久久| 亚洲免费人成在线视频观看| 国产精品区免费视频| 久久久99国产精品免费| 日韩午夜黄色| 久久久一区二区| 一本色道久久综合亚洲精品按摩 | 国产视频一区二区在线观看| 欧美在线视频导航| 欧美国产一区二区在线观看 | 夜夜夜精品看看| 国产精品第三页| 久久久久国色av免费观看性色| 亚洲缚视频在线观看| 午夜在线精品偷拍| 亚洲福利国产| 国产精品一区二区三区乱码| 老司机精品久久| 亚洲欧美激情一区| 亚洲黄色影院| 欧美在线观看一区二区三区| 亚洲成色999久久网站| 国产精品久久久久久亚洲毛片 | 韩日精品中文字幕| 欧美视频免费| 免费毛片一区二区三区久久久| 亚洲一二三区精品| 亚洲电影av| 久久精品视频在线看| 亚洲女同精品视频| 最新日韩中文字幕| 国产综合久久久久久| 欧美午夜在线| 欧美精品一区二区三区在线看午夜| 欧美在线二区| 亚洲一区二区三区免费在线观看 | 国产精品另类一区| 欧美激情a∨在线视频播放| 久久国产主播| 亚洲欧美日韩精品久久亚洲区| 日韩视频二区| 亚洲精品美女免费| 欧美激情视频一区二区三区免费 | 欧美99久久| 久久久www| 久久精品一区二区三区不卡| 亚洲欧美成人一区二区三区| 亚洲麻豆av| 亚洲国产午夜| 欧美激情在线狂野欧美精品| 麻豆久久精品| 美女任你摸久久| 久久亚洲不卡| 久久婷婷久久一区二区三区| 久久高清国产| 久久久久久**毛片大全| 久久久夜色精品亚洲| 麻豆精品91| 欧美承认网站| 亚洲国产经典视频| 亚洲高清视频在线观看| 亚洲激情欧美| 亚洲伦理自拍| 亚洲一区二区免费| 欧美一区2区三区4区公司二百| 欧美亚洲一区二区在线| 欧美一区二区三区在| 欧美尤物一区| 久久综合伊人77777| 欧美激情1区2区3区| 欧美系列一区| 国产视频欧美视频| 国产综合色一区二区三区| 激情亚洲成人| 亚洲精品免费在线| 亚洲一区二区伦理| 欧美一区二区精美| 免费一区视频| 99视频精品| 久久精品午夜|