查看完整版本: [-- 【本书勘误】 --]

QTCN开发网 -> 《Qt高级编程》专栏 -> 【本书勘误】 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

yfx2003 2011-06-27 14:15

【本书勘误】

本书勘误信息。
更新日期:20110701


如表——
页码,提出人 问题描述修改建议Check by
166,dbzhang800 QThreadPool::globalInstance()方法会向Qt的全局对象 QThreadPool 返回一个指针 QThreadPool::globalInstance()会返回一个Qt的全局QThreadPool对象指针 Xchinux
214,dbzhang800 这个模型子类用 QAbstractItemModel::data() 方法取代了 Qt::DisplayRole,以保证 这个模型子类只替换QAbstractItemModel::data() 方法中的 Qt::DisplayRole,以确保 yfx2003
222,dbzhang800 这个连接保证了无论何时光标被移除(无论是通过键盘还是鼠标),都调用这个槽。 这个连接会保证光标只要一移动(无论是通过键盘还是鼠标),就会调用这个槽。 yfx2003
227,dbzhang800 我们还可以使用 QTextEdit 子类化 QPlainTextEdit,它更为便捷,因为它提供了 当然,本应子类化QPlainTextEdit的,但使用QTextEdit会更为便捷,因为它提供了许多有用的槽,如QTextEdit::setFontItalic(),而QPlainTextEdit则不会提供这些槽。 yfx2003
231,dbzhang800 一个可选方法是使用 sender(),以进一步使用SignalMapper 代替使用sender()的方法是使用SignalMapper;那样会提供更好的封装性… yfx2003
231,dbzhang800 当用户启动上下文菜单(通过右键点击或通过使用一个平台定义的键序列)时将在构造函数中建立一个信号-槽连接,并调用这个槽。 当用户启动上下文菜单(通过右键点击或通过使用一个与平台相关的键序列)时,由于在构造函数中建立了信号-槽连接,这个槽就会得到调用。 yfx2003
231,dbzhang800 最后弹出菜单,使用Menu::exec()把相对窗口部件的位置转换为相对屏幕(也就是全局)的位置。 最后弹出菜单,完成把与窗口部件相关的位置转换成与屏幕(也就是全局)相关的位置,再由QMenu::exec()使用。 dbzhang800
  242,dbzhang800 这个方法会创建一个QString的HTML,然后 这个方法会把HTML变成一个QString,然后yfx2003
286,dbzhang800 如前面所述,使用 dynamic_cast<>()让程序不依赖于RTTI 如前所述,使用 dynamic_cast<>()让程序依赖于RTTI dbzhang800
  289,dbzhang800 在前面提醒注意的,使用 dynamic_cast<>()使程序不依赖RTTI是否可用 正如之前提到的那样,使用dynamic_cast<>()会使程序依赖RTTI的可用性 dbzhang800





yfx2003 2011-07-01 12:45
请勿再本贴中灌水或者阐述与勘误无关的话题,谢谢合作

dbzhang800 2011-07-13 13:22
上午公司断电了,静心看了看本书的1.1节。然后感觉下面3处有些别扭,和大家探讨一下


page 5

我们已经简单、直接地调用了requestXml(),但考虑到编程风格,还是建议尽量少用在各个构造函数中构造一个对象的“create”方法,也尽量少用单触发器来调用哪些构造后初始化方法(post-construction initializing method)。


We could have simply called requestXml() directly, but as a matter of style we prefer to restrict ourselves to calling “create” methods that contribute to the construction of an object in constructors, and to call any post-construction initializing method using a single shot timer.


注:原文意思
* 1. 本可以直接用 requestXml() (但是没有用,而是用的后面的提到的 post-construction..)。
* 2. 鼓励使用 单触发的 定时器 (来调用构造后初始化方法)

page 8

QDomDocument 类是 Qt 的 QtXml 模块的一部分,因此可以使用它,但必须在应用程序的.pro文件里面加上 QT += xml 这一行。


The QDomDocument class is part of Qt’s QtXml module, so to be able to use it we must add the line QT += xml to the application’s .pro file.


注:因此可以... 但... (感觉比较别扭),似乎该改成,“要能够使用它,我们必须..."

page 10

首先,要检查已接收到一个某种类型的重定向,看它是否是我们期望的反馈结果。


We begin by checking to see if instead of the reply we are expecting we have received a redirect of some kind.


注:检查的是,接收到的是否是某种重定向而不是我们期待的reply

dbzhang800 2011-07-13 21:21
真不好意思,刚整理出第一章的1.2节,似乎有点多


翻译真的不容易,各位老大辛苦了


page 18



这类应用程序的危险在于,它们很容易在网站中发生变化,但与强大的易用性所能节省的时间相比,这些变化就微不足道了。特别是当网站拥有大量用户时,这种程序更能发挥其效用。当然,我们可以控制这些改变,使其只影响后台使用的JavaScript而完全不会影响网站的源代码。

The danger of such applications is that they can be vulnerable to changes in the web site, but this may be outweighed by the time savings achieved by the greater convenience of use—particularly if the site has a large number of users. Also, we might be able to contain the effects of such changes so that they only affect the JavaScript we use behind the scenes without requiring source code changes
at all.

注:
* 1. 危险在于,面对网站发生的变化,应用程序很脆弱。
* 2. 我们“包容”而不是“控制”这些变化。所谓的包容是指:使变化只影响我们(应用程序)后台使用的JavaScript 而完全不需要修改我们的(C++)代码。

page 19

这两个对象会在后台建立QWebpage对象和再调用数据对象QWebage...

These objects create QWebPage objects behind the scenes—recall that QWebPages are data objects—and have their QWebPages download a pecified page.

注:recall 似乎应该翻译成 回想,记起

page 19



当在页面中建立这两个对象时,引入它们的JavaScript,这样做有助于提取相对链接。


They then inject the JavaScript they are given when they are constructed into the page, and this is used to extract relevant links.

注:
* 它们将该JavaScript注入到页面
* 该JavaScript是在它们自己被构造时传入的
* 这个JavaScript被用来提取相对链接。



page 20

如果文件系统中没有保存脚本,就直接返回,把嵌入到可执行文件目录中的脚本作为资源。


But if the script isn’t in the filesystem then we fall back to using
a script that has been embedded in the executable as a resource.


注:如果该脚本在文件系统中不存在,我们将使用一个已经作为资源被嵌入到可执行程序中的脚本。



page 25



第一个参数是JavaScript 可用对象的名称(在此例中,是linkFetcher),QObject的第二个参数是实际对象的一个引用。此时,它是LinkFetcher类的一个实例。

The string first argument is the name that the object will be accessible as in JavaScript (in this example, linkFetcher), and the QObject second argument is a reference to the actual object—in this case an instance of the LinkFetcher class itself.

注:这是在介绍 {{{void QWebFrame::addToJavaScriptWindowObject(const QString &, QObject *)}}} 这个函数。第一个String类型参数... 第二个QObject类型参数...



page 25



如果加载失败,那么通知所有连接对象。否则,检查QString scriptOrScriptName 私有成员变量是真的拥有一个脚本还是仅有脚本的名称;如果是后者,我们尝试写入脚本的文本。打开二进制模式的文件,并利用静态 QString::fromUtf8()方法把 QFile::readAll()方法返回的QByteArray转换成Unicode,而不是创建一个QTextStream。一旦脚本就绪,让QWebPage的主框架对它进行评估,然后通知所有连接对象转换已成功。

If the load failed we notify any connected objects. Otherwise we check to see if the QString scriptOrScriptName private member variable holds an actual script or only the name of a script; and in the latter case we attempt to read in the script’s text. Instead of creating a QTextStream, we open the file in binary mode and convert the QByteArray returned by the QFile::readAll() method into Unicode using the static QString::fromUtf8() method. Once the script is ready we tell the QWebPage’s main frame to evaluate it, and then we notify any connected objects that we have successfully finished.

注:
* read in the script's text  ==> "写入"脚本的文本 ? (笔误)
* 打开二进制模式的文件 ==> 以二进制模式打开文件?
* evaluate ==> 用"评估"是否合适(其他地方也有出现)?



page 25



既然已经为链接检查器设定了一个引用,那么链接检查器本身就是可以被JavaScript脚本读取的,那么脚本就可以调用任何链接检查器的公共槽,并获取它的属性值。在这个示例中,为使用JavaScript脚本而使用了addUrlAndName槽。

Since we have set a reference to the link checker itself as an object accessible to the JavaScript script, that script can call any of the link checker’s public slots and access its properties. In this case we have provided the addUrlAndName() slot expressly for the use of JavaScript scripts.


注:
* 由于我们已经将链接检查器自身的引用设置为可被JavaScript脚本访问的对象...
* 在这种情况下,我们特意提供了 addUrlAndName() 槽...



page 26



图 1.11 显示了如何为一个网页添加应用程序的QObject,在网页上下文中执行的JavaScript可以同时获取页面的HTML元素(通过文档对象模型)和所有页面访问的应用程序的QObject。

Figure 1.11 illustrates how by adding an application QObject to a web page, JavaScript executed in the context of the web page can access both the page’s HTML elements (via the Document Object Model), and any application QObjects we give the page access to.


注:
* how by ... 这句如何翻译?
* 可访问的是:  所有我们给于该page访问权限的QObject

page 26



需要特别注意的是最后一个声明,这里参考了C++的链接获取器对象,用linkFetcher调用了LinkFetcher::addUrlAndName()。

The key point to notice is the last statement, where we call LinkFetcher::addUrlAndName() using the linkFetcher reference to the C++ link fetcher object.


注:
* 声明 ==> 语句
* 参考 ==> 引用



page 26



因为这样会妨碍GUI应用程序的时间循环。

since they block the GUI application’s event loop.


注:笔误?


page 27


讨论一下如何使用类似引入JavaScript来调试应用程序是非常值得的(它并不容易)!

it is worth discussing how to debug applications that use injected JavaScript like this—since it isn’t easy!


注:值得讨论的是如何调试使用了这种注入式JavaScript的应用程序。



page 27

这对哪些仍然稳定或我们已经拥有控制权的网站非常有用。


which is very convenient for web sites that we know will remain stable or that we have control over.


注:似乎应该翻译成,将会保持稳定



page 27



因此,在这种情况下,我们必须在简单和方便之间做出抉择,改变我们的JavaScript脚本,使其...

So, in each case, we must make the trade-off between the ease and convenience with which we can change our JavaScript scripts to keep up with web site changes, versus the power and asynchronicity of Qt’s networking and web classes which make it easy to present a responsive user interface and allow us to do all our web programming in pure C++.


注:似乎应该是在 “简单和方便” 与 "强大和异步" 之间做出抉择



page 28


我们把Qt的全局函数qsrand() 作为Qt的随机数发生器。

Qt’s global qsrand() function is used to seed Qt’s random number generator.


注:为Qt的随机数发生器提供种子。

page 29



调用 ctreatePlygin() 方法

the createPlugin() method is called.


注:排版错误。



page 30


执行过程返回的默认结果是0,在这种情况下,程序渲染的对象是<object>标志的文本(如果存在的话),而不是渲染预期目标。

The default implementation returns 0, and in such cases the <object> tag’s text (if any) is rendered rather than the intended object.


注:
* implementation ==> 执行 vs 实现
* object ==> 目标 vs 对象

XChinux 2011-07-15 22:51
已发邮件通知了相关译者。

gemi 2011-09-26 13:22
书买了,感觉很不错。


查看完整版本: [-- 【本书勘误】 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled