-
Bug
-
Resolution: Done
-
Not Evaluated
-
None
-
4.7.1
-
None
-
04765969d74f4e3f323a4477c41b061e954f6df7, 9be58993bc60cd874068010a920706f2f2868955
While translating the Getting Started Programming with Qt guide for the developer.qt.nokia.com wiki, I stumbled over some oddities in its content:
Download of code samples
For the readers of the guide it surely would be handy if they could download the complete examples in a zip file.
Missing references
In the end of the Hello Notepad section directories part1 resp. part1/debug and part1/release are mentioned. These directories have not been introduced before. Additionally, on windows the path would be part1\debug - with a backslash
Signal/slot connection
In section Subclassing QWidget we read:
The quit() slot can now be connected to signals with a matching signature (any signal that takes no parameters)
That's not the whole truth, we can connect any signal with parameters to slots with parameters that are a (probably empty!) prefix of the signals signature. So we can connect any signal to a slot with an empty parameter list!
Implementation of slots open() and close()
The code sections should display the complete functions, including function signature, not only the body. E.g. like this:
void Notepad::open()
{
// function body
}
Line numbering in code sections
Some of the code blocks do have line numbers, some do not. That's inconsistent.
QFileDialog:: getOpenFileName()
The function not only does return when the user has selected a file name, but also when he hit the abort button
Different level of verbosity in the explanations
In the beginning the verbosity level is quite high, including the explanation of #include statements. Further on this verbosity is not the same. I can understand that it's quite cumbersome to hold that until the very end, but it introduces a strange style of writing. It reads as if different people had written the particular sections.
Wrong code in slots save() and open()
In slot open we operate on a raw QFile, using its readAll; in slot save we use QTextStream for writing. That may not cause problems in 7 bit ASCII world (read: english ) but may cause failures to read the previously written files with the very same program if the file encoding does not match the guess of QTextStream. I'd suggest to use QTextStream for saving the contents too and to explicitly set a text encoding.
Subclassing QWidget not complete
The header file contains a quit() slot which is actually not implemented. Also, the modified main.cpp is missing, so the example cannot be compiled.
The missing code:
void Notepad::quit() { if( QMessageBox::question( this, tr("Quit?"), tr("Do you really want to quit the Notepad?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::Yes ) { qApp->quit(); } }
#include <QtGui> #include "notepad.h" int main(int argv, char **args) { QApplication app(argv, args); Notepad window; window.show(); return app.exec(); }