Advanced Qt Programming

Errata

ISBN-10: 0321635906 – ISBN-13: 978-0321635907

Errata for the First and Second Printings (the errata in the second table were all fixed in the Second Printing)

Issue Resolution Reporter
Page 15. The sidebar gives a very brief summary of the Alt_Key library supplied with the book. Here is the Alt_Key Library Documentation. Author
Pages 355-357. Redundant code. The cursorPositionChanged() signal–slot connection and the cursorPositionChanged() slot appear to be redundant for Qt 4.7+. Yuriy Grihsin

Errata for the First Printing only (additional to the errata above—these are all fixed in the Second and subsequent printings)

Issue Resolution Reporter
Pages 166-167. Subtle bug. In the insertRows() method each new TaskItem is inserted at the end of its parent's list of children rather than at the row specified. Replace the for loop with the following to correct this:
    for (int i = 0; i < count; ++i) {
	TaskItem *item = new TaskItem(tr("New Task"), false);
	parentItem->insertChild(row, item);
    }
(The archives already contain this bug fix.)

In addition, replace the last phrase of the sentence that ends at the top of page 167 with ", and each the child of the parent item at the specified row."

Alexey Smirnov
Page 174. Suboptimal code. In the moveItem() method shown on this page two separate emissions of the dataChanged() signal are made. This works perfectly well for the example application, but is not the best approach to use in the general case. A better way is to emit a single dataChanged() signal that spans the model indexes that have changed, so replace the two emit lines with just this one line:
    emit dataChanged(oldIndex, newIndex);
(The archives already contain this improvement.)
Alexey Smirnov
Page 175. Subtle bug. In the cut() method shown on this page the last assertion will cause the program to crash if the very first item is cut. The solution is to replace the last three lines with these six lines:
    if (parent != rootItem) {
        TaskItem *grandParent = parent->parent();
        Q_ASSERT(grandParent);
        return createIndex(grandParent->rowOfChild(parent), 0, parent);
    }
    return QModelIndex();
What we've done is put the original three lines in a conditional and return an invalid model index (which means the root of the tree) if the condition isn't met. (The archives already contain this improvement.)
Reiner Itschert

Top