Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt Creator can't compile code from Learn QT 5
QtWS25 Last Chance

Qt Creator can't compile code from Learn QT 5

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 2 Posters 688 Views
  • 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
    learnqt
    wrote on last edited by
    #1

    Hi,,

    I am reading chapter 2 from Learn Qt 5 and after typing in a lot of code, I can't make qt creator to compile it.
    Here they are:
    ...\cm\cm-lib\source\models\client.cpp:3: error: expected unqualified-id
    ....\cm\cm-lib\source\models\client.cpp:3:3: error: expected unqualified-id
    cm-lib::cm-lib()
    ^

    What's more, you cannot follow the book exactly, for example when you create a lib, there's no way to find 'Classs information dialogue'. Nor can you find Qt Unit Test. The user interface has changed a lot.

    It even spits out rubbish such as 'width' is an invalid property name.

    Well, I understand that I am using a community version. But this company shouldn't give away buggy software. They must have seen the bug without us reporting it later.

    I am new to QML. What should I do if even a 2-year-old book which teaches you Qt 5 contains code that Qt 5 doesn't compile?

    Thank you for reading.

    J.HilkJ 1 Reply Last reply
    0
    • L learnqt

      Hi,,

      I am reading chapter 2 from Learn Qt 5 and after typing in a lot of code, I can't make qt creator to compile it.
      Here they are:
      ...\cm\cm-lib\source\models\client.cpp:3: error: expected unqualified-id
      ....\cm\cm-lib\source\models\client.cpp:3:3: error: expected unqualified-id
      cm-lib::cm-lib()
      ^

      What's more, you cannot follow the book exactly, for example when you create a lib, there's no way to find 'Classs information dialogue'. Nor can you find Qt Unit Test. The user interface has changed a lot.

      It even spits out rubbish such as 'width' is an invalid property name.

      Well, I understand that I am using a community version. But this company shouldn't give away buggy software. They must have seen the bug without us reporting it later.

      I am new to QML. What should I do if even a 2-year-old book which teaches you Qt 5 contains code that Qt 5 doesn't compile?

      Thank you for reading.

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      hi @learnqt

      Can you show your actual source code, this looks like a misplaced ; to me

      It is true, Qt Creator has changed a lot in the last 2 years. But nothing so much, that things are at completely different locations

      But this company shouldn't give away buggy software

      that is true, sadly nearly every company uses the customer as beta testers these days! Despicable but sadly the norm. I Miss the days where software had to be good on release, because online patching wasn't a thing. Today we get day 1 patches bigger then the distributable 😞

      They must have seen the bug without us reporting it later.

      what bug?

      I am new to QML. What should I do if even a 2-year-old book which teaches you Qt 5 contains code that Qt 5 doesn't compile?

      If code compiled 2 years ago, it will compile today, thats a fundamental thing even to c++ in general. And Qt is guaranteed to be compatible inside a major version ( Qt 4 /5/6 are not necessarily compatible to each other)


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      L 1 Reply Last reply
      3
      • J.HilkJ J.Hilk

        hi @learnqt

        Can you show your actual source code, this looks like a misplaced ; to me

        It is true, Qt Creator has changed a lot in the last 2 years. But nothing so much, that things are at completely different locations

        But this company shouldn't give away buggy software

        that is true, sadly nearly every company uses the customer as beta testers these days! Despicable but sadly the norm. I Miss the days where software had to be good on release, because online patching wasn't a thing. Today we get day 1 patches bigger then the distributable 😞

        They must have seen the bug without us reporting it later.

        what bug?

        I am new to QML. What should I do if even a 2-year-old book which teaches you Qt 5 contains code that Qt 5 doesn't compile?

        If code compiled 2 years ago, it will compile today, thats a fundamental thing even to c++ in general. And Qt is guaranteed to be compatible inside a major version ( Qt 4 /5/6 are not necessarily compatible to each other)

        L Offline
        L Offline
        learnqt
        wrote on last edited by
        #3

        @J-Hilk

        Thanks for the quick answer. It’s a lot of code, but you can download the source from here: https://github.com/PacktPublishing/Learn-Qt-5

        At first I thought I had made some typos so I downloaded the source and strangely it didn’t compile. Please try the ‘cm’ code in chapter 2.

        J.HilkJ 1 Reply Last reply
        0
        • L learnqt

          @J-Hilk

          Thanks for the quick answer. It’s a lot of code, but you can download the source from here: https://github.com/PacktPublishing/Learn-Qt-5

          At first I thought I had made some typos so I downloaded the source and strangely it didn’t compile. Please try the ‘cm’ code in chapter 2.

          J.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @learnqt compiles, links and runs just fine

          fa4bcbdb-0b99-4a52-a3df-ade58d4fec4d-image.png


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          1
          • L Offline
            L Offline
            learnqt
            wrote on last edited by
            #5

            I am running windows 7. You're running a MAC i think. And I can see that you didn't build for android.

            Here's what I did. I doubleclicked on the .pro file and it opened in Qt Creator. I clicked on build. Here's the result.

            Untitled.png

            1 Reply Last reply
            0
            • L Offline
              L Offline
              learnqt
              wrote on last edited by
              #6

              Oh. Never mind. I have solved it.
              I disabled the kit for android. And everything is fine now.

              Thank you for help. You showed me that if it ran on your computer I must have been doing something wrong.

              J.HilkJ 1 Reply Last reply
              0
              • L learnqt

                Oh. Never mind. I have solved it.
                I disabled the kit for android. And everything is fine now.

                Thank you for help. You showed me that if it ran on your computer I must have been doing something wrong.

                J.HilkJ Online
                J.HilkJ Online
                J.Hilk
                Moderators
                wrote on last edited by J.Hilk
                #7

                @learnqt
                actually the creator of this "book" did mess up things as well.

                first of,
                .user files should NEVER EVER be part of a repository and belong into .gitIgnore as they will cause more problems

                secondly, both the test and the ui project depend on the library project. But that is not specified in the cm.pro file

                so change cm.pro to this content:

                TEMPLATE = subdirs
                
                SUBDIRS += \
                    cm-ui \
                    cm-lib \
                    cm-tests
                
                cm-ui.depends = cm-lib
                cm-tests.depends = cm-lib
                message(cm project dir: $${PWD})
                

                Here's what I did. I doubleclicked on the .pro file and it opened in Qt Creator. I clicked on build. Here's the result.

                If you open the project that way, than the default executable will be the test. Testing is not cross platform and will probably fail somehow if you try to build it for android!

                Make sure you select the cm-ui project before compiling:
                40782f93-e7a4-4f89-afcc-8da3cdf7046d-image.png


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                4
                • L Offline
                  L Offline
                  learnqt
                  wrote on last edited by
                  #8

                  Thank you very much.

                  1 Reply Last reply
                  0

                  • Login

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