Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Problem with "C++ GUI Programming with Qt4, 2nd Edition"
So i'm trying to go over Qt with this book "C++ GUI Programming with Qt4, 2nd Edition". Two first exercises worked well with my Qt Creator 4.5.1 and mingw32 but then i got into first "big" program. Qt went apeshit with like 40 errors or something. What am i doing wrong? I guess it's version compatibility problem.
Here you can find complete files:
Exercise i'm talking about starts from page 28. I would link files themselves but i don't have enough privileges.
Hi @LonelyZero and welcome to the forum,
Qt went apeshit with like 40 errors or something
And what are the errors you are getting? Compiler errors? Linker errors? Runtime errors? Without that information it's hard to help you.
As the book was written for Qt4, some things need to be adopted for Qt5 of course. That's usually easy for a programmer with Qt experience, but may be hard for a starter.
welcome to the forums
You need to show the actual errors :)
Oftens, its just small things.
Like other include name or something extra in the .pro file.
Anyway here is Qt5 version of the code
LonelyZero last edited by LonelyZero
Thanks for reply and words of welcome. I thought linked files may say much more than my noobie analysis. You can find the whole project there and try to run it yourself. I don't think there is a way to copy error log and i'm kinda too stupid to feel the difference between linker errors and runtime errors.
Here's example screen of some errors:
Incomplete type often means you forgot the include. ( like #include <QLabel> )
But in this case please check you have
QT += widgets
in the .pro file
also go to
and see if he fixed sample for Qt5
LonelyZero last edited by LonelyZero
The thing is it's not my files. It's book example. Literally took it from the site to compare with my code. So i don't think it's about me forgetting something.
Yep, it's there.
Ok, i'll check it now.
What chapter is it ?
Ag Chap02, find.pro
I thought linked files may say much more than my noobie analysis.
I did not say you should analyze the problem, but you need to give us facts for our analysis. Compiler errors often differ from compiler to compiler and from platform to platform, so it is needed to see what's going wrong on your side.
I don't think there is a way to copy error log
Just go to the compile output pane and you can select the whole compiler log.
and i'm kinda too stupid to feel the difference between linker errors and runtime errors.
Oh. How is your C++ knowledge level? You will need C++ to work with Qt.
Version from github works. Now just need to find the difference. Probably can do it myself.
I had to change forwards to includes
#include <QHBoxLayout> to .cpp
it seems that #include <QtGui>
used to pull in more.
and QT +=widgets
so basically you can fix it with replace
#include <QtGui> with
but NOTE , this is not good style for real projects as it pulls in far more than you need :)
I know basic C++ stuff. Functions, variables, classes. I don't feel like i don't understand the code i've seen so far. It's just all i knew is from couple books i read in free time and i have zero expirience with real software and, erm, error fixing. That's kinda stuff i'm used to. It's for university so don't worry i'm not gonna crash any planes.
Thank you! I'll try that one in couple hours.
I know basic C++ stuff. Functions, variables, classes. I don't feel like i don't understand the code i've seen so far. It's just all i knew is from couple books i read in free time and i have zero expirience with real software and, erm, error fixing.
Then just start coding :) You will get used to error fixing if you do errors, and you will learn a lot. When I started coding, I typed listings from books and so you had to fix lots of errors before the program was running the first time. But you also got a better understanding of the code you're having.
That's kinda stuff i'm used to. It's for university so don't worry i'm not gonna crash any planes.
:) But if you need help building your first plane, just ask here.
Yep, changed forwards into includes and added layout to .cpp. Works perfectly. Thank you, guys.