Oddities in "Getting Started Programming with Qt"
-
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
-
I think it is usually good form to keep the discussion on the (public) forum, even if you address one person in particular. That way, also others have the opportunity to answer as well as learn from that answer.
Like in this case, I might answer - even though my name is not Alexandra - : the right place would be in the Installation and Deployment forum :-)
-
As novice to Qt I followed the source code on the "getting started page":http://doc.qt.nokia.com/4.7/gettingstartedqt.html.
There were several issues I encountered. Alas, if I only had found this thread during one of my earlier searches on google! This would have saved quite a few hours. Thank you to Volker, Bertus and nonot1 and all others for their helpful contributions!There was a lot to be learned by taking this approach, but the learning curve was too steep. Maybe my expectations were set too high after having completed all basic tutorials of Ogre3D without any issues. And the Qt getting started tutorial is well written in that it gives a good overview of Qt and easily is found early on. Perhaps for some the direct move into the "nice tutorials":http://doc.qt.nokia.com/4.7/tutorials.html is a better starting point.
To recap on some other peoples experiences:
(1) "http://developer.qt.nokia.com/forums/viewthread/2253":http://developer.qt.nokia.com/forums/viewthread/2253
(2) "http://www.qtcentre.org/threads/34610-Getting-Started-Programming-with-Qt-tutorial-part2-giving-assertion-fail":http://www.qtcentre.org/threads/34610-Getting-Started-Programming-with-Qt-tutorial-part2-giving-assertion-fail
(3) "http://stackoverflow.com/questions/7314878/not-able-to-find-quit-slot-and-use-q-object-macro":http://stackoverflow.com/questions/7314878/not-able-to-find-quit-slot-and-use-q-object-macro(1) and (2) are complementary in their descriptions. Personally, I preferred the smallest possible change to fix the code by pulling up the line
@QWidget window;@
to a point before the definition of the edit and button widgets. This suffices, because during destruction of the objects on the stack the edit and button widgets are destroyed before their parent. If the parent is destroyed first, users of the Visual Studio will see a
@debug assertion failed ... _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)@
because the parent auto-destroys its children and the destruction of a non-existant object from the stack fails.As Volker and Bertus have pointed out, the implemention of quit() is missing. One solution is to implement it. The other is to use the default slot of qApp. My impression was that quit should never have been declared at all, thus preferring the latter solution.
Using "this" (as in the original sample) fails because quit() is neither a slot of QWidget nor of QMainWindow. And there is no need to implement quit() in the first place if "qApp" is used instead of "this":
@connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));@
If one wishes to define quit(), a short version can be used too:
@void Notepad::quit() {
QCoreApplication::instance()->quit(); // or use qApp->quit();
}@If the unpatched code is used, then users of Visual Studio 2010 will see the
linker choke:
@moc_Notepad.obj : error LNK2019: unresolved external symbol "public: void __thiscall Notepad::quit(void)" (?quit(at)Notepad
(at)(at)QAEXXZ) referenced in function "public: virtual int __thiscall Notepad::qt_metacall(enum QMetaObject::Call,int,void *
*)" (?qt_metacall(at)Notepad(at)(at)UAEHW4Call(at)QMetaObject(at)(at)HPAPAX(at)Z)@Other recommendations on the web have suggested one of the following to fix this and similar messages. Here they are not needed, but I found them to be good general advice:
Check the source code and config settings in the .pro file. Check if the moc files were created, compiled and linked. Check that the project is in a clean state before building.The include directive
@#include <QtGui>@
is non-functional in Visual Studio 2010 under the default settings.
@error: can not open source file "QtGui"@
Only a Qt project that is provided by the Visual Studio QT plugin has the
additional include path of
@$(QTDIR)\include\QtGui@
Without the plugin or when using a default empty VC++ project, this path has not been set. It is not needed, when one uses a single additional include path
@$(QTDIR)\include @
Which works well enough when specifying
@#include <QtGui\QtGui>@
Or include the headers individually. One file is not located in the QtGui folder
@#include <QtCore\QTextStream>@
Actually, I liked that fact that the tutorial does not require the Visual Studio addin at all. It would be helpful if this would be mentioned. Perhaps by linking out to the prerequisites needed to build the sample code?One thing specific to Visual Studio 2010 SP1 is that a warning from IntelliSense about inability to generate PCH will show up. To avoid this warning I used an empty main.h header. The warning is documented and occurs, because it cant find a declaration that is outside of an #if-block.
After taking care of the above noted issues, the final sample application builds flawlessly in Visual Studio with default settings. Nonetheless the application will crash before showing the window, if the previously posted bugfix in this thread for
@saveAction = new QAction(tr("&Open"), this); // should be openAction = ...
saveAction = new QAction(tr("&Save"), this);@
is not introduced, because openAction is not initialized before it is used.Hope this is able to help some people who have recently started with Qt.
-
wow. How is it 2013 and these issues are still unresolved?
Just got started coding in cxx and qt and found this site. Add another issue to this tutorial: all the "learn more" links all go to the same anchor. That is the first anchor about windows.
Seriously, can someone fix this?
-
Hi cxx::qmanic,
Thanks for bringing up the "Learn more" issue. I've filed a bug report at https://bugreports.qt-project.org/browse/QTBUG-32110
The documentation linked from the original post is the archived version of Qt 4.7 docs, which are no longer being developed. The currently-maintained versions of Qt are Qt 5.0 (released in 2012) and Qt 4.8 (released in 2011).
If you're new, I highly recommend starting with Qt 5. You can find the updated documentation at http://doc-snapshot.qt-project.org/qt5-release/qtdoc/gettingstartedqt.html -- the original issues are gone.
If you find any more issues, please report them to https://bugreports.qt-project.org -- reports in this forum unlikely to be seen by Qt's engineers and will get buried under all the other posts.
-
"The documentation linked from the original post is the archived version of Qt 4.7 docs, which are no longer being developed. The currently-maintained versions of Qt are Qt 5.0 (released in 2012) and Qt 4.8 (released in 2011)."
Not really sure what you're saying here. The documentation I'm speaking of is located here: http://qt-project.org/doc/qt-4.8/gettingstartedqt.html and if 4.8 is still maintained then it would be nice to update the documentation accordingly so Devs can have reliable documentation to learn from.
"If you’re new, I highly recommend starting with Qt 5. You can find the updated documentation at http://doc-snapshot.qt-project.org/qt5-release/qtdoc/gettingstartedqt.html — the original issues are gone."
Which is fine if a developer wanted to start with 5.0, but if they were to start with 4.8 - which we are currently using at work for example - then those issues would still persist. So again, I iterate my first point: just update the docs for 4.8 to what it should be. It'll only frustrate developers.
Also I noticed in your bug report that you created a ticker for 5.0 - which still has the same anchor issue. Do both 5.0 and 4.8 "learn more" sections link to the same place? Is this what you were saying in your response thus Updating one will update the other? If so great, if not again my first point about correcting the docs for 4.8.
Thanks for taking the time to reply and even creating a bug report. Much appreciated.
-
[quote author="cxx::qmanic" date="1372610754"][quote author="JKSH" date="1372564126"]The documentation linked from the original post is the archived version of Qt 4.7 docs, which are no longer being developed. The currently-maintained versions of Qt are Qt 5.0 (released in 2012) and Qt 4.8 (released in 2011).[/quote]
Not really sure what you're saying here. The documentation I'm speaking of is located here: http://qt-project.org/doc/qt-4.8/gettingstartedqt.html and if 4.8 is still maintained then it would be nice to update the documentation accordingly so Devs can have reliable documentation to learn from.[/quote]I was saying that the issues only exist in Qt 4.7; everything that Volker, Bertus and densewater mentioned is fixed in the Qt 4.8 page that you linked. The only issue left that I can see is the anchoring, which now has a formal bugtracker ticket.nonot1's struggle with make is toolchain-specific -- Qt supports many different tools; showing all the variants of make will just clutter the tutorial. As for missing DLLs, that's a topic on deployment which has "entire pages":http://qt-project.org/doc/qt-4.8/deployment.html#platform-specific-notes dedicated to it -- it's not quite "Getting Started" material (and it's not Qt-specific either).
Have I missed anything?
The issues still exist in the archived Qt 4.7 docs, because that's what it is -- an archived copy, which won't (and shouldn't) be changed.
[quote author="cxx::qmanic" date="1372610754"]Also I noticed in your bug report that you created a ticker for 5.0 - which still has the same anchor issue. Do both 5.0 and 4.8 "learn more" sections link to the same place? Is this what you were saying in your response thus Updating one will update the other? If so great, if not again my first point about correcting the docs for 4.8.[/quote]They don't link to the same place, as they have independent code bases. To keep the 2 versions in sync, the procedure is to push changes to Qt 5.x first, then cherry-pick important fixes over to Qt 4.8.[/quote]
[quote author="cxx::qmanic" date="1372610754"]Thanks for taking the time to reply and even creating a bug report. Much appreciated.[/quote]You're welcome :) That's what a community is for!