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


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()");  回復  更多評論
  
<2006年12月>
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| 国产一区二区三区视频在线观看 | 久久精品亚洲一区二区三区浴池| 麻豆freexxxx性91精品| 欧美一级久久久久久久大片| 麻豆精品传媒视频| 午夜精品婷婷| 午夜免费在线观看精品视频| 欧美欧美在线| 国产精品yjizz| 国产精品久久久久久久午夜 | 国产精品久久久久永久免费观看 | 亚洲美女视频网| 一本高清dvd不卡在线观看| 亚洲视频在线观看网站| 亚洲校园激情| 国产精品久99| 狠狠色综合日日| 久久久国产精品亚洲一区 | 亚洲人成网站在线观看播放| 99re成人精品视频| 亚洲欧美日韩视频一区| 亚洲人在线视频| 欧美福利一区| 亚洲一级在线| 国产欧美91| 在线观看成人小视频| 亚洲精品久久嫩草网站秘色 | 亚洲一区在线免费观看| 久久不射2019中文字幕| 欧美日韩精品系列| 在线观看欧美| 亚洲第一区在线观看| 麻豆成人在线播放| 一区二区三区 在线观看视频| 久久精品一区二区| 久久久久久伊人| 国产精品白丝av嫩草影院| 午夜国产一区| 亚洲精品中文字幕女同| 午夜精品久久久久影视 | 欧美午夜精品伦理| 欧美中文在线观看| 亚洲日本视频| 久久久999成人| 亚洲人成人99网站| 亚洲永久在线观看| 亚洲国产老妈| 久久免费视频这里只有精品| 99在线热播精品免费99热| 国产精品综合色区在线观看| 亚洲天堂网在线观看| 欧美+日本+国产+在线a∨观看| 亚洲一区中文| 欧美成年人视频网站欧美| 国产精品视频一二| 一区电影在线观看| 午夜久久久久久久久久一区二区| 国内精品美女av在线播放| 午夜电影亚洲| 久久人人97超碰人人澡爱香蕉| 国产麻豆视频精品| 免费欧美视频| 欧美一区二区福利在线| 亚洲每日更新| 精品91视频| 久久婷婷久久一区二区三区| 久久久国产精品一区二区中文 | 久久在线免费观看视频| 欧美日韩亚洲免费| 狠狠色综合网站久久久久久久| 亚洲激精日韩激精欧美精品| 欧美在线视频日韩| 亚洲国产网站| 亚洲欧美成人网| 欧美另类69精品久久久久9999| 久久精品国产久精国产思思| 日韩视频一区二区在线观看 | 欧美成人一区二区三区| 亚洲欧美制服中文字幕| 欧美极品一区| 黄色欧美日韩| 亚洲欧美综合国产精品一区| 亚洲人成7777| 巨胸喷奶水www久久久免费动漫| 国产精品一区二区在线| 亚洲精品一区中文| 在线日韩一区二区| 午夜在线不卡| 欧美福利电影在线观看| 国产美女精品一区二区三区| 亚洲精品国产精品乱码不99按摩| 国产九九精品| 亚洲欧美一区二区视频| 99视频精品免费观看| 欧美精品一区二区三| 农村妇女精品| 亚洲狠狠丁香婷婷综合久久久| 亚洲欧美高清| 久久精品二区| 国产精品丝袜xxxxxxx| 亚洲一级在线观看| 亚洲一区二区三区在线| 久久精品最新地址| 香蕉久久夜色精品| 久久久欧美一区二区| 久久九九精品| 国产区精品视频| 午夜精品久久久久久久久| 亚洲欧洲精品一区二区三区波多野1战4| 美女黄网久久| 国产精品美女主播| 久久精品国产一区二区电影 | 久久久天天操| 性久久久久久久久久久久| 国产情侣久久| 欧美在线观看www| 欧美高清在线视频观看不卡| 伊人夜夜躁av伊人久久| 免费人成精品欧美精品| 在线性视频日韩欧美| 国产精品久久精品日日| 一区二区三区国产精品| 久久精品视频在线观看| 国产曰批免费观看久久久| 美日韩在线观看| 亚洲国产片色| 午夜日本精品| 国产一区二区三区久久久| 久久本道综合色狠狠五月| 亚洲午夜性刺激影院| 欧美性一区二区| 久久久激情视频| 午夜在线视频观看日韩17c| 欧美成人免费全部观看天天性色| 亚洲成人资源| 欧美精品一区二区在线观看| 亚洲激情电影在线| 国产一区二区三区四区老人| 久久久久99| 亚洲精品国产系列| 亚洲免费av电影| 久久av一区| 亚洲国产精品va| 亚洲免费福利视频| 国内久久精品| 免费成人网www| 性欧美精品高清| 欧美a级片网站| 欧美与欧洲交xxxx免费观看| 国产一区视频网站| 欧美午夜精品伦理| 欧美一区二区三区免费视| 亚洲欧洲另类国产综合| 亚洲欧美激情四射在线日| 91久久久久久国产精品| 欧美午夜不卡在线观看免费 | 欧美综合77777色婷婷| 亚洲国产一区视频| 国产精品国产三级国产普通话三级 | 精品9999| 亚洲国产综合在线看不卡| 久久精品国产清高在天天线| 亚洲精品色婷婷福利天堂| 久久久久国色av免费看影院| 国内精品免费在线观看| 亚洲午夜精品久久久久久app| 免费亚洲电影在线| 性久久久久久久| 免播放器亚洲一区| 久久久久久9| 一本久道久久综合中文字幕| 亚洲国产欧美一区二区三区同亚洲| 欧美视频中文字幕| 欧美日韩中文另类| 免播放器亚洲| 免费不卡欧美自拍视频| 亚洲欧美日韩一区二区三区在线观看 | 欧美一区二区高清在线观看| 亚洲深夜激情| 最新国产の精品合集bt伙计| 欧美福利网址| 久久久久久久一区| 久久一区二区精品| 久久国产高清| 久久久久久久一区| 久久成人免费| 久久精品中文字幕一区| 午夜精品美女久久久久av福利| 亚洲一区二区三区乱码aⅴ| 亚洲国产欧美日韩| 一本到12不卡视频在线dvd| 在线播放不卡| 亚洲日本免费| 亚洲国产精品视频一区| 亚洲精品久久久久久久久| 亚洲国产视频一区二区|