Programming with Qt, 2nd Edition by Matthias Kalle Dalheimer The unconfirmed error reports are from readers. They have not yet been approved or disproved by the author or editor and represent solely the opinion of the reader. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification This page was updated June 29, 2005. UNCONFIRMED errors and comments from readers: <26> Example 2-2; In line 12: QLabel* mylabel = new QLabel( "Hello world", mywidget); The word "mywidget" or the entire line should be displayed in bold face, because is has changed since the previous example. Readers might take the code from the previous example and not change that line because it isn't displayed in bold face. This causes compile or run problems. The change is noted in the text, though. [37,457] Exercises on that page (#1); the solution presented in the back of the book for exercise on page 37 simply doesn't work, and the program operates with all the same characteristics as before. This could be caused by: 1. the fact that i'm running in Blackbox on a x86 Debian Linux machine 2. the language has changed so that a slider does send the signal valueChanged as the slider is moved, and not just on the mouse release. [39] method mouseMoveEvent; Programm qtscripple1.cpp: the drawing QPainter object windowpainter has always the color white untill I resize the window. After creating a QPaint object and setting the size it works fine. void ScribbleWindow::mouseMoveEvent(QMouseEvent* event) { //create a QPen object for setting the penwidth QPen pen; pen.setWidth(1); //create a QPainter object for drawing onto the window QPainter windowpainter; //an another QPainter object for drawing into an off-screen pixmap QPainter bufferpainter; //start painting windowpainter.begin(this); //this painter paints onto the window bufferpainter.begin(&_buffer); //and this one paints in the buffer //allocating the pen to both the window and the buffer windowpainter.setPen(pen); bufferpainter.setPen(pen); //draw a line in both the window and the buffer windowpainter.drawLine(_last, event->pos()); bufferpainter.drawLine(_last, event->pos()); //done with painting windowpainter.end(); bufferpainter.end(); //remember the current mouse position _last = event->pos(); } I don't know if this problem is only on SunOs available. (44) 5th paragraph; Last sentence of paragraph begins: For example, when the File menu Should be: For example, when the Color menu Explanation: You choose the drawing color from the color-menu and not from the file- menu! (55) Exercise 1; The original text is: redpixmap = new QPixmap(20, 20); redpixmap.fill(red); I think it should be changed to: Qpixmap redpixmap(20, 20); redpixmap.fill(red); [86-87] bottom of 86 and all of 87; Three of the lines of code to set the style do not compile: QApplication::setStyle( new QWindowsStyle ); QWidgetListIt widgetlist_it( *widgetlist ); QObjectListIt objectlist_it( *objectlist ); The command-line switches to set the style have no effect. {117} Second last paragraph; It says that you "rarely need to instantiate QDockWindow yourself". It should read "rarely need to instantiate QDockArea yourself". {145} Code snippit in the 2nd paragraph; QErrorMessage* errorMessage = new QErrorMessage( parent ); parent->message( "Your hard disk is on fire!" ); Should be: QErrorMessage* errorMessage = new QErrorMessage( parent ); errorMessage->message( "Your hard disk is on fire!" ); (154) 2nd paragraph, second sentence. Just below the Figure 5-7; "The Back and Front buttons are automatically configured..." There is no "Front" button, so it should probably say: "The Back and Next buttons are automatically configured..." [175] 3rd item, QPtrDict; This describes QDict, not QPtrDict. The heading and two references in the descriptive paragraph should be changed. The later QPtrDict paragraph (p.176) also has an error: "This class is similar to QPtrDict..." should be "This class is similar to QDict..." (234) Table 10-1 in the 2nd Metacharacter Example; The Example for the Metacharacter "{n,}" should be changed from: a{,3}b to: a{3,}b (235) Table 10-2; '\.' doesn't work. '\\.' has to be used to escape the dot. I suppose the same applies to all the sequences in that table up to '\}'. (236) Table 10-2; The Sequence \s is explained twice. The second explanation, being less precise, could probably be omitted. (240) line 12, line 22; in the lines which reads: "virtual bool startElement(const QString& namespace, const QString& localName, ..." the term "namespace" is actually a keyword in C++ as there is namespaces in C++. it should be changed to something like "nspace" for the parameter name. (241) third line of the code on the top of the page; the line: "reader.parse(source);" should be: "reader.parse(inputSource);" as this has defined from the last line of code on page 240. {251} 8th last sentence of the code; The code example on page 251 (second edition) causes a segmentation fault when the "delete fileinfolist" statement is reached. I tried using a similar function to the one in the book in an application and got this segfault. I then posted the problem to the qt-interest mailing-list and got this answer from Dimitri at Trolltech. I also downloaded the example from your site to be sure it is an error, and I still get an segfault. [begin] Re: Segfault when manually deleting QPtrList From: Dimitri Papadopoulos trolltech.qt-interest Refs: 1 > I get a segfault when the program attempts to delete fileinfolist (a > QFileInfoList). > [...] > const QFileInfoList* fileinfolist = dir.entryInfoList(); > [...] > //delete fileinfolist; // segfaults The documentation of QDir::entryInfoList() states: The returned pointer is a const pointer to a QFileInfoList. The list is owned by the QDir object and will be reused on the next call to entryInfoList() for the same QDir instance. If you want to keep the entries of the list after a subsequent call to this function you will need to copy them. http://doc.trolltech.com/3.0/qdir.html#entryInfoList You shouldn't delete an object owned by another object. This causes a double deletion - and a segfault. Dimitri [end] {268} 1st paragraph; This paragraph says that by surrounding a declaration with extern { ... } you tell the compiler to use C linkage. In fact it must be extern "C" { ... } for this to work. [271] below #ifdef Q_WS_WIN statement; The 'dirlister.cpp' example will fail on WinXP Pro or WinNT (have not checked other versions). It appears to me that if a command cannot be run from 'Start > Run' dialog, it cannot be run from the QProcess. EXISTING:------------------------------ #ifdef Q_WS_WIN process->addArgument( "dir" ); #else CHANGE TO:----------------------------- #ifdef Q_WS_WIN process->addArgument( "cmd.exe /C dir" ); #else END Snippets ------------------------- I have found that my results look better if I comment out the line: edit->append( "\n" ); on page 270. For more cmd.exe information, type 'cmd /?' at the dos prompt. (Thanks to replies from Torbjorn Eriksson and Soeren Fietzke at the Trolltech newsgroup) (295) Last line of 4th paragraph; "... below the mouse painter." Should be, "... below the mouse pointer." {Chapter 8} All references to QPtrDict should be changed to QDict [304] second paragraph following example 16-1; QApplication::installGlobalEventFilter() should be QApplication::installEventFilter(); According to TrollTech's documentation: "It's also possible to filter all events for the entire application, by installing an event filter on QApplication." (363) Table 22-1; the qmake option for multithread is "thread" and not "qhread" {367} last statement in function HTTPMirrorServer::newConnection(); change from: stream << "
";

change to:
   stream << "HTTP/1.0 200 OK\r\n";
   stream << "Content-Type: text/html\r\n";
   stream << "\r\n";
   stream << "
";

Otherwise my IE 6.0 will not display the mirrored
text correctly.


{386}  1st line, 2nd paragraph;
"The browser first calls the method RotatePlugin::create(), ..."

should be,

"The browser first calls the method QNPlugin::create(), ..."


{386}  1st line, 3rd paragraph;
"RotatePlugin::create() is only called once, ..."

Should be,

"QNPlugin::create() is only called once, ..."


(386)  end of 3rd paragraph;
"... which the browser demands by calling RotatePlugin:: newIn-
stance()."

Should be,

"... which the browser demands by calling RotatePlugin::newIn-
stance()."

i.e., without the space after the scope operator.


{387}  1st line of page 387;
"The browser uses streamAsFile() to tell ..."

Should be,

"The browser uses newStreamCreated() to tell ..."


{423}  In code snippet at top of page;
The destructor ~PizzaEntryImpl() is not present in the code snippet.
The function definition is present in the code snippet at the top
of page 424.This omission causes the compiler to issue a warning.


{424}  In code snippet at bottom of page;
The code statement  pizzaEntry.show(); is missing from the code snippet. It should
appear as follows:

#include 
#include <"PizzaEntryImpl.h>

int main( int argc, char* argv[] )
{
   QApplication app( argc, argv );

   PizzaEntryImpl pizzaEntry( 0, "pizza entry", true );
   app.setMainWidget( &pizzaEntry );
   pizzaEntry.show();
   int ret = pizzaEntry.exec();
   return ret;
}

The omission prevents the window from displaying on screen when
the program is run.


[425]  line 11;
moc -o moc_PizzaEntryTest.cpp PizzaEntry.cpp

should be...

moc -o moc_PizzaEntryTest.cpp PizzaEntry.h


[425]  top of page, second line:      moc -o moc_PizzaEntryTest.cpp PizzaEntryTest.cpp;
When running this command on a Linux system with the g++ compiler(version 3.0.2), the following error is reported at the prompt:

PizzaEntryTest.cpp:0: Warning: No relevant classes found. No output generated.

All input files were double checked for mistakes( typos, syntax, etc.) and there were none. What is the problem? Why is the file
moc_PizzaEntryTest.cpp not included in the input for the g++ compiler
on line 3 at the top of the page?

This problem appears to be duplicated in the command list for
the Windows with Visual C++ option on the fifth line below the phrase "and for Windows with Visual C++" on the same page.




(490)  QSettings class, 248-250;
The index entry,

QSettings class, 248-250

should be,

QSettings class, 254-257