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. [Solved] "The header file 'game.h' doesn't include <QObject>."
QtWS25 Last Chance

[Solved] "The header file 'game.h' doesn't include <QObject>."

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.5k 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.
  • D Offline
    D Offline
    Deedasmi
    wrote on 4 Nov 2014, 17:25 last edited by
    #1

    Hey all, I have a problem I can't figure out. I'm trying to implement slots and signals, but QTcreator is throwing a fit. The error thrown is "Undefined reference to game::playerName(std::string)'" in moc_game.cpp, but I believe it is caused by the lines at the top of the moc (see pasebin below).

    moc_game.cpp; http://pastebin.com/6mpxBKsD (error on line 80)
    game.h: http://pastebin.com/74szJpu6

    I've tried a variety of different things, but I'm unsure what is going wrong. Google led to a few results, but nothing that helped. One thing I saw was that an incorrect .pro file could cause it. Here is mine: http://pastebin.com/z5S1aKZZ

    Hoping someone here can help me out a bit.Thanks for any assistance!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 4 Nov 2014, 21:22 last edited by
      #2

      Hi and welcome to devnet,

      The error means that you didn't implement playerName. Slots need to be implemented in order to build your class.

      Also since you are using std::string (why not QString ?) as parameter type you'll have to register that custom type.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Deedasmi
        wrote on 4 Nov 2014, 21:55 last edited by
        #3

        [quote author="SGaist" date="1415136164"]Hi and welcome to devnet,

        The error means that you didn't implement playerName. Slots need to be implemented in order to build your class.

        Also since you are using std::string (why not QString ?) as parameter type you'll have to register that custom type.[/quote]

        I forgot the game:: on my implementation. Thanks for pointing me in the right direction!

        I was using std::string as I was using code that was written before I started using Qt. Thanks for letting me know it doesn't work out of the box there.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 5 Nov 2014, 00:06 last edited by
          #4

          You're welcome !

          Have a look at the "Signals and Slots" chapter of Qt's documentation, you'll see how to do it properly.

          Since it's build now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          2/4

          4 Nov 2014, 21:22

          • Login

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