Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with "C++ GUI Programming with Qt4, 2nd Edition"
Forum Updated to NodeBB v4.3 + New Features

Problem with "C++ GUI Programming with Qt4, 2nd Edition"

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 4.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LonelyZero
    wrote on 19 May 2018, 06:42 last edited by
    #1

    Hey, folks.

    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's book itself:
    https://tfetimes.com/wp-content/uploads/2015/09/c-gui-programming-with-qt-4-2ndedition.pdf

    Here you can find complete files:
    http://www.informit.com/store/c-plus-plus-gui-programming-with-qt4-9780132354165

    Exercise i'm talking about starts from page 28. I would link files themselves but i don't have enough privileges.

    A 1 Reply Last reply 19 May 2018, 06:47
    0
    • L LonelyZero
      19 May 2018, 06:42

      Hey, folks.

      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's book itself:
      https://tfetimes.com/wp-content/uploads/2015/09/c-gui-programming-with-qt-4-2ndedition.pdf

      Here you can find complete files:
      http://www.informit.com/store/c-plus-plus-gui-programming-with-qt4-9780132354165

      Exercise i'm talking about starts from page 28. I would link files themselves but i don't have enough privileges.

      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 19 May 2018, 06:47 last edited by
      #2

      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.

      Regards

      Qt has to stay free or it will die.

      L 1 Reply Last reply 19 May 2018, 06:59
      1
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 19 May 2018, 06:55 last edited by mrjj
        #3

        Hi
        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
        https://github.com/mutse/qt5-book-code

        1 Reply Last reply
        1
        • A aha_1980
          19 May 2018, 06:47

          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.

          Regards

          L Offline
          L Offline
          LonelyZero
          wrote on 19 May 2018, 06:59 last edited by LonelyZero
          #4

          @aha_1980

          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:

          0_1526713248532_stupid.jpg

          A 1 Reply Last reply 19 May 2018, 07:07
          1
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 19 May 2018, 07:03 last edited by mrjj
            #5

            Hi
            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
            https://github.com/mutse/qt5-book-code
            and see if he fixed sample for Qt5

            L 1 Reply Last reply 19 May 2018, 07:05
            3
            • M mrjj
              19 May 2018, 07:03

              Hi
              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
              https://github.com/mutse/qt5-book-code
              and see if he fixed sample for Qt5

              L Offline
              L Offline
              LonelyZero
              wrote on 19 May 2018, 07:05 last edited by LonelyZero
              #6

              @mrjj

              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.

              0_1526713549991_stupid_2.jpg

              Ok, i'll check it now.

              1 Reply Last reply
              2
              • M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 19 May 2018, 07:07 last edited by mrjj
                #7

                Hi
                What chapter is it ?

                Ag Chap02, find.pro

                L 1 Reply Last reply 19 May 2018, 07:10
                0
                • L LonelyZero
                  19 May 2018, 06:59

                  @aha_1980

                  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:

                  0_1526713248532_stupid.jpg

                  A Offline
                  A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on 19 May 2018, 07:07 last edited by
                  #8

                  @LonelyZero said in Problem with "C++ GUI Programming with Qt4, 2nd Edition":

                  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.

                  Qt has to stay free or it will die.

                  L 1 Reply Last reply 19 May 2018, 07:20
                  3
                  • M mrjj
                    19 May 2018, 07:07

                    Hi
                    What chapter is it ?

                    Ag Chap02, find.pro

                    L Offline
                    L Offline
                    LonelyZero
                    wrote on 19 May 2018, 07:10 last edited by
                    #9

                    @mrjj

                    Version from github works. Now just need to find the difference. Probably can do it myself.

                    M 1 Reply Last reply 19 May 2018, 07:11
                    1
                    • L LonelyZero
                      19 May 2018, 07:10

                      @mrjj

                      Version from github works. Now just need to find the difference. Probably can do it myself.

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 19 May 2018, 07:11 last edited by mrjj
                      #10

                      @LonelyZero
                      I like to use
                      http://winmerge.org/
                      for such tasks.

                      update:
                      for learning
                      I had to change forwards to includes

                      class QCheckBox;
                      class QLabel;
                      class QLineEdit;
                      class QPushButton;

                      #include <QDialog>
                      #include <QLabel>
                      #include <QLineEdit>
                      #include <QPushButton>
                      #include <qcheckbox.h>

                      and add
                      #include <QHBoxLayout> to .cpp
                      it seems that #include <QtGui>
                      used to pull in more.

                      and QT +=widgets
                      to .pro

                      so basically you can fix it with replace
                      #include <QtGui> with
                      #include <QtWidgets>
                      but NOTE , this is not good style for real projects as it pulls in far more than you need :)

                      L 1 Reply Last reply 19 May 2018, 07:21
                      2
                      • A aha_1980
                        19 May 2018, 07:07

                        @LonelyZero said in Problem with "C++ GUI Programming with Qt4, 2nd Edition":

                        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.

                        L Offline
                        L Offline
                        LonelyZero
                        wrote on 19 May 2018, 07:20 last edited by
                        #11

                        @aha_1980

                        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.

                        0_1526714274741_0175fe2d-bf2c-4070-9e0c-d65d8970dcbf-image.png

                        A 1 Reply Last reply 19 May 2018, 07:32
                        0
                        • M mrjj
                          19 May 2018, 07:11

                          @LonelyZero
                          I like to use
                          http://winmerge.org/
                          for such tasks.

                          update:
                          for learning
                          I had to change forwards to includes

                          class QCheckBox;
                          class QLabel;
                          class QLineEdit;
                          class QPushButton;

                          #include <QDialog>
                          #include <QLabel>
                          #include <QLineEdit>
                          #include <QPushButton>
                          #include <qcheckbox.h>

                          and add
                          #include <QHBoxLayout> to .cpp
                          it seems that #include <QtGui>
                          used to pull in more.

                          and QT +=widgets
                          to .pro

                          so basically you can fix it with replace
                          #include <QtGui> with
                          #include <QtWidgets>
                          but NOTE , this is not good style for real projects as it pulls in far more than you need :)

                          L Offline
                          L Offline
                          LonelyZero
                          wrote on 19 May 2018, 07:21 last edited by
                          #12

                          @mrjj

                          Thank you! I'll try that one in couple hours.

                          1 Reply Last reply
                          0
                          • L LonelyZero
                            19 May 2018, 07:20

                            @aha_1980

                            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.

                            0_1526714274741_0175fe2d-bf2c-4070-9e0c-d65d8970dcbf-image.png

                            A Offline
                            A Offline
                            aha_1980
                            Lifetime Qt Champion
                            wrote on 19 May 2018, 07:32 last edited by
                            #13

                            @LonelyZero said in Problem with "C++ GUI Programming with Qt4, 2nd Edition":

                            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.

                            Qt has to stay free or it will die.

                            1 Reply Last reply
                            3
                            • L Offline
                              L Offline
                              LonelyZero
                              wrote on 20 May 2018, 00:39 last edited by
                              #14

                              Yep, changed forwards into includes and added layout to .cpp. Works perfectly. Thank you, guys.

                              1 Reply Last reply
                              2

                              1/14

                              19 May 2018, 06:42

                              • Login

                              • Login or register to search.
                              1 out of 14
                              • First post
                                1/14
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved