Oddities in "Getting Started Programming with Qt"
-
I've just finished a "German version":http://developer.qt.nokia.com/wiki/Einstieg_in_die_Programmierung_mit_Qt of the "Getting Started Programming with Qt":http://doc.qt.nokia.com/4.7/gettingstartedqt.html guide and came over some oddities during translation:
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":http://doc.qt.nokia.com/4.7/gettingstartedqt.html#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":http://doc.qt.nokia.com/4.7/gettingstartedqt.html#subclassing-qwidget we read:bq. 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. -
I found another one:
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:
from notepad.cpp:
@
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();
}
}
@main.cpp:
@
#include <QtGui>
#include "notepad.h"int main(int argv, char **args)
{
QApplication app(argv, args);Notepad window; window.show(); return app.exec();
}
@ -
There's a ticket "QTWEBSITE-163":http://bugreports.qt.nokia.com/browse/QTWEBSITE-163 for this now.
-
Bugs in Qt documentation should be filed against QTWEBSITE or against Qt itself? I'd say the latter, because the documentation is also shipped offline (in assistant / html).
[Edited to add]: or, of course, Trolls can add a QTDOCS category for bugs in the "official" Qt documentation...
-
I would file against QTWEBSITE and choose doc.qt.nokia.com as the "project" for the issue. Marius did not veto against that for another one ("QTWEBSITE-161":http://bugreports.qt.nokia.com/browse/QTWEBSITE-161) - so it seems ok :-)
-
[quote author="Volker" date="1294157071"]I would file against QTWEBSITE and choose doc.qt.nokia.com as the "project" for the issue.[/quote]
This is the correct way. When you create the bug report -> just start typing "doc" in the field called "Component/s" and it pops up:
!http://developer.qt.nokia.com/uploads/image_upload/mariusg_2011-01-04_000192.png(bugreport)!
-
In the section "Using a QMainWindow" there are a few typo's in the 2nd code snippet:
@
Notepad::Notepad()
{
saveAction = new QAction(tr("&Open"), this);
saveAction = new QAction(tr("&Save"), this);
exitAction = new QAction(tr("E&xit"), this);
...
connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
...
@Which should be:
@
Notepad::Notepad()
{
openAction = new QAction(tr("&Open"), this);
saveAction = new QAction(tr("&Save"), this);
exitAction = new QAction(tr("&Exit"), this);
...
...
connect(exitAction, SIGNAL(triggered()), this, SLOT(quit()));
...
@connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); also works, but then QT's standard quit()-function is used, not the one with the confirmation window (QMessageBox) that Volker posted earlier.
-
As a new user, my first attempt at trying Qt was "Getting Started Programming with Qt". It seemed like a reasonable choice given the title. :-)
I've had much trouble given the subtle errors (and errors by omission) in the document, and now I have a rather involuntary bad taste for Qt.
The very first document your website recommends reading should be much higher quality. :)
At the very least, test all the steps on a fresh install of Qt on popular newbie platforms. (Windows, Mac, and Ubuntu come to mind)
Thank you
-
@Alexandra : Thank you for sending this to the doc team.
Also, the tutorial tells you to use the "make" command, but this is missing from the Qt SDK 1.1 RC installed environment. Dunno if that's correct or not. Seems wrong, though. Tested on Windows 7, using the "Qt 4.7.3 for Desktop (MinGW)" command prompt window. This should be fixed, or if it's not a bug, spoken about in the tutorial.
(By searching the /bin folder, I found "mingw32-make.exe"... annoying to type, but that seemed to work.)
The final as-built applications also only work when instantiated via the development command line window. I assume it's a DLL linking issue, but no mention is made in the tutorial on how to fix this. So, how am I supposed to share my new text-edit application with friends? ;-) This should be spoken about in the tutorial.
Thank you
-
Hi nonot1,
the make command you need, depends on the tool-chain you use. On windows, this is typically mingw (mingw32-make.exe) or MSVS (nmake).
For linux using gcc it's make.
Regarding the start of the app, the dlls need to be found. On windows, thats is done in the following way:
Look in the executable dir
look in the current dir
look inside windows system dir
search the %PATH% environment variable for it
On Linux, it's different (but I'm not sure, how), also for Mac.
What works for windows, copy the dlls to the executable :-)
This is also stated in the docs for "distributing":http://doc.qt.nokia.com/4.7/deployment.html -
Hi Gerolf,
Thank you for clearing up those points. (And providing background justification)
As I said, I did eventually figure our how to build and run the application, but the main issue is that the introduction tutorial does not even mention these issues. (Aside from other errors covered earlier in this thread.)
Not to get the thread off-topic, but there should also be a simple introductory level how-to for using the QtSDK, and it's supplied MinGW tool-chain, to generate size-minimized "single .exe" Qt applications.
-
-
Quick question.....
Some of the issues I had were due to rough edges in the 1.1 RC SDK install.
Where is the correct place to ask about these?
-
[quote author="nonot1" date="1304358997"]
@AlexandraQuick question.....
Some of the issues I had were due to rough edges in the 1.1 RC SDK install.
Where is the correct place to ask about these?
[/quote]Just for future reference: you can send a personal message to a person by using the link on her/his profile page