Results 1 to 7 of 7

Thread: Undefined reference to '(class name)::connectSignSlot() in moc_(class name).o

  1. #1
    Join Date
    Oct 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Undefined reference to '(class name)::connectSignSlot() in moc_(class name).o

    For the record: I'm pretty new to Qt, though I have a few c++ programming classes under my belt. My current class (c++, primarily) is the first exposure I've had to the Qt language.

    Now, I'm making a pretty complex application that is probably a little beyond what we're expected to do for our term project. I think I have everything but this one error figured out. The error, indicated in the title, seems like it requires a very advanced knowledge of the language to even know what the deuce the connectSignSlot() function is/does. The fact that it's in a ".o" file scares me. Google has zero, yes zero, results about the error message or the function (which, I'm guessing, is part of a pretty basic library that I have no business messing about with). I can only imagine that it has something to do with the guts of the language actually doing the connecting between signals and slots. The error is in a moc_(class name).o for a custom class.

    Also for the record: I was pretty careless and thrashed out a bunch of code without testing it because I was nearly certain it would work. Shame on me.

    If this error can be resolved I think the application will indeed work as intended, but I am stumped. Anyone? Let me know if you need to see some code.

    Unnecessary fluff: the application is a rudimentary character generator for D&D 3.5, only handling (all the following terms refer to their Dungeons and Dragons definitions) nonmagical core classes and core races (though I may drop the races down to a smaller selection). It will handle levels 1-20, no multiclassing, and it won't have any equipment to deal with. It will calculate BAB, saving throws, AC, initiative, abilities that don't have a numerical effect, and maybe a couple other things.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Undefined reference to '(class name)::connectSignSlot() in moc_(class name).o

    Is the header for the class "class name" included in the HEADERS varaible of the PRO file?
    Does "class name" derive from QObject and contain a Q_OBJECT macro?
    Have you rerun qmake since changing either of the items above?

  3. #3
    Join Date
    Oct 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Undefined reference to '(class name)::connectSignSlot() in moc_(class name).o

    Yes to each of the second two questions. I don't have access to the code at the moment, so I'm not sure about whether or not it's included in the .pro but I'll figure that out as soon as I'm home.

  4. #4
    Join Date
    Oct 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Undefined reference to '(class name)::connectSignSlot() in moc_(class name).o

    Yes to all three, and my professor has never seen that error before. I'm stumped. I did try to start a new project and add the sources and headers to it, but it produced the same error. I will try to copy/paste the contents of the sources and headers instead of bringing over the files themselves. Maybe that'll do something.

  5. #5
    Join Date
    Sep 2015
    Posts
    50
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Undefined reference to '(class name)::connectSignSlot() in moc_(class name).o

    Try to clean, run qmake, then rebuild all. If you're using the QtCreator app right-clicking the Project name in the left panel will bring up the option to execute qmake. Make sure that this is happening by checking the output of the compiler. Then rebuild.

    Assuming you ahve done this, try deleting the build directory of your project (contains your object files and intermediate build files) and then execute qmake, and rebuild. I run into this whenever I add a signal/slot combo to anything.

    If those don't do it then post your files I'll see if anything is awry.

    Cheers!
    - Caolan O'Domhnaill

  6. #6
    Join Date
    Oct 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Undefined reference to '(class name)::connectSignSlot() in moc_(class name).o

    Worked on this off and on for a little while. No luck. Did all the suggestions and nothing worked. The actual error is this:
    Qt Code:
    1. moc_ability.o:-1: error: undefined reference to `Ability::connectSignSlot()'
    To copy to clipboard, switch view to plain text mode 
    *I'm testing the code marker, never used it before. Source and headers to follow once I make sure I'm doing it right.*

    Here's everything relevant. I didn't include the stuff for widpushbutton as it has always worked properly. Its purpose is to send a widget pointer when clicked so the stackedwidget can switch to the proper screen and it does this without problems. The "race" class isn't written up yet. All it has is an empty default constructor declaration (in the header) and definition (in the source), so I didn't include those.

    ability.h:
    Qt Code:
    1. #ifndef ABILITY_H
    2. #define ABILITY_H
    3.  
    4. #include <QString>
    5. #include <QObject>
    6.  
    7. class Ability : public QObject
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. Ability();
    13. Ability(Ability&);
    14. Ability(QString,QString,int,int);
    15. ~Ability();
    16. Ability& operator=(int);
    17. virtual QString getDispName();
    18. virtual QString getDesc();
    19. virtual int getLevel();
    20. virtual int getVal();
    21. virtual void setDispName(QString);
    22. virtual void setDesc(QString);
    23. virtual void setLevel(int);
    24. virtual void setVal(int);
    25. virtual void connectSignSlot();
    26.  
    27.  
    28. signals:
    29. void sendVal(int);
    30. void sendVal(QString);
    31. void sendLevel(int);
    32. void sendLevel(QString);
    33. void sendDispName(QString);
    34. void sendDesc(QString);
    35.  
    36. public slots:
    37. void recvDispName(QString);
    38. void recvDesc(QString);
    39. void recvLevel(int);
    40. void recvVal(int);
    41. /*void callName();
    42.   void callDesc();
    43.   void callLevel();
    44.   void callVal();
    45. */
    46. private:
    47. int level;
    48. int val;
    49. QString dispName;
    50. QString desc;
    51. };
    52.  
    53. #endif // ABILITY_H
    To copy to clipboard, switch view to plain text mode 

    ability.cpp:
    Qt Code:
    1. #include "ability.h"
    2.  
    3. Ability::Ability() {
    4.  
    5. }
    6.  
    7. Ability::Ability(Ability & other) {
    8. setDispName(other.getDispName());
    9. setDesc(other.getDesc());
    10. setLevel(other.getLevel());
    11. setVal(other.getVal());
    12. }
    13.  
    14. Ability::Ability(QString inNa,QString inDe,int inLe,int inVa) {
    15. setDispName(inNa);
    16. setDesc(inDe);
    17. setLevel(inLe);
    18. setVal(inVa);
    19. }
    20.  
    21. Ability::~Ability() {
    22.  
    23. }
    24.  
    25. Ability& Ability::operator=(int n) {
    26. setVal(n);
    27.  
    28. return *this;
    29. }
    30.  
    31. QString Ability::getDispName() {
    32. return dispName;
    33. }
    34.  
    35. QString Ability::getDesc() {
    36. return desc;
    37. }
    38.  
    39. int Ability::getVal() {
    40. return val;
    41. }
    42.  
    43. int Ability::getLevel() {
    44. return level;
    45. }
    46.  
    47. void Ability::setDispName(QString in) {
    48. dispName = in;
    49. }
    50.  
    51. void Ability::setDesc(QString in) {
    52. desc = in;
    53. }
    54.  
    55. void Ability::setLevel(int n) {
    56. level = n;
    57. emit sendLevel(level);
    58. }
    59.  
    60. void Ability::setVal(int n) {
    61. val = n;
    62. emit sendVal(val);
    63. }
    64.  
    65. void Ability::recvDispName(QString in) {
    66. setDispName(in);
    67. emit sendDispName(dispName);
    68. }
    69.  
    70. void Ability::recvDesc(QString in) {
    71. setDesc(in);
    72. emit sendDesc(desc);
    73. }
    74.  
    75. void Ability::recvLevel(int in) {
    76. setLevel(in);
    77. emit sendLevel(QString::number(level));
    78. }
    79.  
    80. void Ability::recvVal(int in) {
    81. setVal(in);
    82. emit sendVal(QString::number(val));
    83. }
    To copy to clipboard, switch view to plain text mode 

    character.h:
    Qt Code:
    1. #ifndef CHARACTER_H
    2. #define CHARACTER_H
    3.  
    4. #include <cstdlib>
    5. #include <ctime>
    6. #include <map>
    7. #include <string>
    8. #include <vector>
    9. #include <QApplication>
    10. #include <QWidget>
    11. #include <QLineEdit>
    12. #include "ability.h"
    13. #include "race.h"
    14.  
    15. class Character : public QObject
    16. {
    17. Q_OBJECT
    18.  
    19. public:
    20. Character();
    21. ~Character();
    22. int* roll4d6();
    23. void reroll(int*);
    24. bool ones(int*);
    25. void setAC();
    26. int getAC();
    27. std::map<QString,Ability*> vitalStats;
    28. std::pair<QString,Ability*> armorClass;
    29. Race race;
    30. void setVital(QString,int);
    31.  
    32. signals:
    33.  
    34. public slots:
    35. void recvVital(QString,int);
    36.  
    37. private:
    38. int AC;
    39. };
    40.  
    41. #endif // CHARACTER_H
    To copy to clipboard, switch view to plain text mode 

    character.cpp:
    Qt Code:
    1. #include "character.h"
    2.  
    3. Character::Character() {
    4. vitalStats["STR"] = new Ability("STR", "Strength: A character's raw physical power",0,10);
    5. vitalStats["DEX"] = new Ability("DEX", "Dexterity: A measure of both manual dexterity and how quick s/he is on his/her feet",0,10);
    6. vitalStats["CON"] = new Ability("CON", "Constitution: A measure of physical resilience",0,10);
    7. vitalStats["INT"] = new Ability("INT", "Intelligence: An analog to IQ, INT 10 ~ IQ 100",0,10);
    8. vitalStats["WIS"] = new Ability("WIS", "Wisdom: A measure of street smarts and common sense",0,10);
    9. vitalStats["CHA"] = new Ability("CHA", "Charisma: A measure of a character's likeability and personal presence",0,10);
    10.  
    11. armorClass.first = "AC";
    12. armorClass.second = new Ability("Armor Class","A measure of how hard it is to land a hit on a character; derived from armor, magic, and dexterity",0,10);
    13. }
    14.  
    15. Character::~Character() {
    16.  
    17. }
    18.  
    19. int* Character::roll4d6() {
    20. srand(time(0)); rand(); rand();
    21. int rolls[5];
    22. for (size_t i=0; i<4; i++) {
    23. rolls[i] = rand()%6+1;
    24. }
    25. return rolls;
    26. }
    27.  
    28. void Character::setAC() {
    29. AC = 10+vitalStats["DEX"]->getVal();
    30. }
    31.  
    32. int Character::getAC() {
    33. return AC;
    34. }
    35.  
    36. void Character::setVital(QString name,int n) {
    37. vitalStats[name]->setVal(n);
    38. //qDebug() << QString::number(stats["STR"]);
    39. }
    40.  
    41. void Character::recvVital(QString name,int n) {
    42. setVital(name,n);
    43.  
    44. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp:
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "widpushbutton.h"
    3. #include "character.h"
    4. #include <QApplication>
    5. #include <QPushButton>
    6. #include <QLabel>
    7. #include <QBoxLayout>
    8. #include <QFrame>
    9. #include <QStackedWidget>
    10. #include <QSpinBox>
    11. #include <QTextEdit>
    12. #include <QRadioButton>
    13. #include <QLineEdit>
    14. #include <QGridLayout>
    15.  
    16. int main(int argc, char *argv[])
    17. {
    18. QApplication a(argc, argv);
    19. MainWindow w;
    20. w.show();
    21.  
    22. QStackedWidget *mainCentral = new QStackedWidget; ///< main window handling
    23. w.setCentralWidget(mainCentral);
    24. /**
    25.   * the individual window widgets
    26.   */
    27. QWidget *welcScrn = new QWidget; ///< for welcome
    28. QWidget *rollScrn = new QWidget; ///< for roll stat-gen
    29. QWidget *raceScrn = new QWidget; ///< for choosing player's race
    30. QWidget *classScrn = new QWidget; ///< for choosing player's class
    31. QWidget *charSheet = new QWidget; ///< for displaying basic character sheet
    32.  
    33.  
    34. Character *merp = new Character;
    35.  
    36. /**
    37.   * adding all windows to stackedwidget
    38.   */
    39. mainCentral->addWidget(welcScrn);
    40. mainCentral->addWidget(rollScrn);
    41. mainCentral->addWidget(raceScrn);
    42. mainCentral->addWidget(classScrn);
    43. mainCentral->addWidget(charSheet);
    44.  
    45.  
    46. //////////Welcome Scrn//////////////////////////////////////////////////
    47.  
    48.  
    49. WidPushButton *rollStats = new WidPushButton(rollScrn,"Roll"); ///< button to send player to roll stat-gen
    50. QObject::connect(rollStats,SIGNAL(widClicked(QWidget*)),mainCentral,SLOT(setCurrentWidget(QWidget*)));
    51.  
    52. /**
    53.   * welcome screen greetings/info
    54.   */
    55. QLabel *spacer1 = new QLabel("");
    56. QLabel *welcome = new QLabel("<html><h3>Welcome to the D&D 3.5 Character Creator</h3></html>");
    57. QLabel *welcomeSub = new QLabel("Currently only supports non-magical core classes. No multiclassing.");
    58. QLabel *chooseGenMethod = new QLabel("How would you like to generate your stats?");
    59. QLabel *chooseGenMethodSub = new QLabel("(this choice can only be made once per character)");
    60.  
    61. /**
    62.   * layouts for welcome screen formatting
    63.   */
    64. QVBoxLayout *welcScrnBones = new QVBoxLayout;
    65. QVBoxLayout *welcScrnTop = new QVBoxLayout; welcScrnTop->setAlignment(Qt::AlignTop);
    66. QVBoxLayout *welcScrnBot = new QVBoxLayout; welcScrnBot->setAlignment(Qt::AlignBottom);
    67. QHBoxLayout *buttons1 = new QHBoxLayout;
    68.  
    69. buttons1->addWidget(rollStats);
    70. buttons1->addWidget(spacer1);
    71.  
    72. QFrame *separator1 = new QFrame();
    73. separator1->setFrameShape(QFrame::HLine);
    74. separator1->setFrameShadow(QFrame::Sunken);
    75.  
    76. welcScrnTop->addWidget(welcome);
    77. welcScrnTop->addWidget(welcomeSub);
    78. welcScrnBones->addLayout(welcScrnTop);
    79. welcScrnBones->addWidget(separator1);
    80. welcScrnBot->addWidget(chooseGenMethod);
    81. welcScrnBot->addWidget(chooseGenMethodSub);
    82. welcScrnBot->addLayout(buttons1);
    83. welcScrnBones->addLayout(welcScrnBot);
    84.  
    85. welcScrn->setLayout(welcScrnBones);
    86.  
    87.  
    88. //////////Roll //////////////////////////////////////////////////
    89.  
    90.  
    91. QVBoxLayout *rollBones = new QVBoxLayout;
    92.  
    93. WidPushButton *rollNextScrn = new WidPushButton(raceScrn, "Accept"); ///< button to accept stats and proceed to race selection
    94. rollNextScrn->setToolTip("Make sure your vital statistics\nare set as you want them;\nyou will not be able to change them\nfor this character.");
    95. QObject::connect(rollNextScrn,SIGNAL(widClicked(QWidget*)),mainCentral,SLOT(setCurrentWidget(QWidget*)));
    96.  
    97. /**
    98.   * @brief placeholderA
    99.   *
    100.   * just read it in runtime
    101.   */
    102. QLabel *placeholderA = new QLabel("I have code already written in c++ for rolling stats.\nThe method is to roll 4d6, or four 6-sided dice, and add\nthe highest three results (possible 3[3x1] minimum through\n18[3x6] maximum). The user is allowed one reroll, but the\nuser must take the reroll immediately after a 4d6 roll. They\ncannot wait until after all rolls have been made to retro-\nactively apply their reroll. The reroll is very specific:\nif any of the four results from rolling one of the 4d6 is a\n\"1\", the user may reroll all ones from that 4d6 until they are\nno longer 1\'s. Again, this may only happen once so the program\nmust keep track of whether or not the reroll has been used. I\nwill only implement a simplified point buy for now.");
    103.  
    104. rollBones->addWidget(placeholderA);
    105. rollBones->addWidget(rollNextScrn);
    106. rollScrn->setLayout(rollBones);
    107.  
    108.  
    109. //////////Race Select //////////////////////////////////////////////////
    110.  
    111.  
    112. QHBoxLayout *raceBones = new QHBoxLayout;
    113. QVBoxLayout *raceList = new QVBoxLayout;
    114.  
    115. QFrame *separator3 = new QFrame;
    116. separator3->setFrameShape(QFrame::VLine);
    117. separator3->setFrameShadow(QFrame::Sunken);
    118.  
    119. WidPushButton *raceNextScrn = new WidPushButton(classScrn, "Accept"); ///< button to accept choice of race and proceed to class selection
    120. QObject::connect(raceNextScrn,SIGNAL(widClicked(QWidget*)),mainCentral,SLOT(setCurrentWidget(QWidget*)));
    121.  
    122. /**
    123.   * @brief raceListItems
    124.   *
    125.   * Each race will be hard-coded with its own list of stat pluses and minuses, and its list of abilities.
    126.   * Abilities that directly affect character creation will be represented on the final Character Sheet page.
    127.   */
    128. QRadioButton *raceListItems[7];
    129. raceListItems[0] = new QRadioButton("Dwarf");
    130. raceListItems[1] = new QRadioButton("Elf");
    131. raceListItems[2] = new QRadioButton("Gnome");
    132. raceListItems[3] = new QRadioButton("Half-Elf");
    133. raceListItems[4] = new QRadioButton("Half-Orc");
    134. raceListItems[5] = new QRadioButton("Halfling");
    135. raceListItems[6] = new QRadioButton("Human");
    136. for (size_t i=0; i<7; i++) raceList->addWidget(raceListItems[i]);
    137.  
    138. QTextEdit *raceAbilitiesList = new QTextEdit;
    139. raceAbilitiesList->setText("This will hold line-separated race ability descriptions, including\n\ntype (extraordinary[EX:], supernatural[SU:],and spell-like[SP:]).");
    140.  
    141. raceBones->addLayout(raceList);
    142. raceBones->addWidget(separator3);
    143. raceBones->addWidget(raceAbilitiesList);
    144.  
    145. raceList->addWidget(raceNextScrn);
    146.  
    147. raceScrn->setLayout(raceBones);
    148.  
    149.  
    150. //////////Class Select//////////////////////////////////////////////////
    151.  
    152.  
    153. QHBoxLayout *classBones = new QHBoxLayout;
    154. QVBoxLayout *classList = new QVBoxLayout;
    155. QHBoxLayout *levelsAccept = new QHBoxLayout;
    156.  
    157. WidPushButton *classNextScrn = new WidPushButton(charSheet, "Accept"); ///< button to accept choice of class and levels, and proceed to character sheet page
    158. QObject::connect(classNextScrn,SIGNAL(widClicked(QWidget*)),mainCentral,SLOT(setCurrentWidget(QWidget*)));
    159.  
    160. QLabel *lvl = new QLabel("Levels");
    161.  
    162. QFrame *separator4 = new QFrame;
    163. separator4->setFrameShape(QFrame::VLine);
    164. separator4->setFrameShadow(QFrame::Sunken);
    165.  
    166. QRadioButton *classListItems[4];
    167. classListItems[0] = new QRadioButton("Barbarian");
    168. classListItems[1] = new QRadioButton("Fighter");
    169. classListItems[2] = new QRadioButton("Monk");
    170. classListItems[3] = new QRadioButton("Rogue");
    171. for (size_t i=0; i<4; i++) classList->addWidget(classListItems[i]);
    172.  
    173. classList->addSpacing(150);
    174. classList->addWidget(lvl);
    175.  
    176. QSpinBox *levels = new QSpinBox;
    177. levels->setRange(1,20);
    178. levelsAccept->addWidget(levels);
    179. levelsAccept->addWidget(classNextScrn);
    180. classList->addLayout(levelsAccept);
    181.  
    182. QTextEdit *classAbilitiesList = new QTextEdit;
    183. classAbilitiesList->setText("This will hold line-separated class ability descriptions, including\n\nlevel gained and type (extraordinary[EX:],supernatural[SU:], and spell-like[SP:]).");
    184.  
    185. classBones->addLayout(classList);
    186. classBones->addWidget(separator4);
    187. classBones->addWidget(classAbilitiesList);
    188.  
    189. classScrn->setLayout(classBones);
    To copy to clipboard, switch view to plain text mode 
    to be continued...

    ...continued

    Qt Code:
    1. //////////Char. Sheet //////////////////////////////////////////////////
    2.  
    3. QHBoxLayout *charBones = new QHBoxLayout;
    4.  
    5. /////Stats //////////
    6. QVBoxLayout *statsAndSaves = new QVBoxLayout;
    7. QWidget *statsAndSavesWidg = new QWidget; ///< for enforcing a width
    8. statsAndSavesWidg->setFixedWidth(250);
    9. QGridLayout *statLayout = new QGridLayout;
    10. QGridLayout *saveLayout = new QGridLayout;
    11.  
    12. QLabel *statHeads[3]; ///< column headers for stats pane
    13. statHeads[0] = new QLabel("Stat");
    14. statHeads[1] = new QLabel("Score");
    15. statHeads[2] = new QLabel("Modifier");
    16. for (size_t i=0; i<3; i++) statLayout->addWidget(statHeads[i],0,i);
    17.  
    18. QLabel *statLabels[6];
    19. statLabels[0] = new QLabel("STR");
    20. statLabels[1] = new QLabel("DEX");
    21. statLabels[2] = new QLabel("CON");
    22. statLabels[3] = new QLabel("INT");
    23. statLabels[4] = new QLabel("WIS");
    24. statLabels[5] = new QLabel("CHA");
    25. for (size_t i=0; i<6; i++) statLayout->addWidget(statLabels[i],i+1,0); ///<seed first column with labels
    26.  
    27. QLabel *statScores[6];
    28. for (size_t i = 0; i<6; i++) {
    29. QObject::connect(merp->vitalStats[statLabels[i]->text()],SIGNAL(sendVal(QString)),statScores[i],SLOT(setText(QString)));
    30. }
    31. for (size_t i = 0; i<6; i++) {
    32. statLayout->addWidget(statScores[i],i+1,1); ///< seed second column with scores
    33. }
    34.  
    35. QLabel *statBonus[6];
    36. for (size_t i = 0; i<6; i++) {
    37. statBonus[i] = new QLabel;
    38. QString ind = statLabels[i]->text();
    39. int mod = -5+((merp->vitalStats[ind])->getVal())/2;
    40. if (mod>=0) {
    41. QString text = "+";
    42. }
    43. text+=QString::number(mod); statBonus[i]->setText(text);
    44. statLayout->addWidget(statBonus[i],i+1,2); ///< seed 3rd column with modifier values
    45.  
    46. }
    47. statLayout->setAlignment(Qt::AlignLeft);
    48.  
    49.  
    50.  
    51. QFrame *separator5 = new QFrame;
    52. separator5->setFrameShape(QFrame::HLine);
    53. separator5->setFrameShadow(QFrame::Sunken);
    54.  
    55.  
    56. /////Saves //////////
    57.  
    58. QLabel *saveHeads[5]; ///< column headers for saves pane
    59. saveHeads[0] = new QLabel("Save");
    60. saveHeads[1] = new QLabel("Total=");
    61. saveHeads[2] = new QLabel("Base+");
    62. saveHeads[3] = new QLabel("Stat+");
    63. saveHeads[4] = new QLabel("Misc");
    64. for (size_t i=0; i<5; i++) saveLayout->addWidget(saveHeads[i],0,i);
    65.  
    66. QLabel *saveLabels[3];
    67. saveLabels[0] = new QLabel("FORT: ");
    68. saveLabels[0]->setToolTip("Fortitude: Constitution-based");
    69. saveLabels[1] = new QLabel("REFL: ");
    70. saveLabels[1]->setToolTip("Reflex: Dexterity-based");
    71. saveLabels[2] = new QLabel("WILL: ");
    72. saveLabels[2]->setToolTip("Will: Wisdom-based");
    73. for (size_t i=0; i<3; i++) saveLayout->addWidget(saveLabels[i],i+1,0); ///< seed save labels to 1st column
    74.  
    75. QLabel *saveBase[3];
    76. for (size_t i=0; i<3; i++) {
    77. saveBase[i] = new QLabel(QString::number(i));
    78. saveLayout->addWidget(saveBase[i],i+1,2); ///< seed random-ish values as base save values
    79. }
    80.  
    81. QLabel *saveStat[3];
    82. saveStat[0] = new QLabel(statBonus[2]->text());
    83. saveStat[1] = new QLabel(statBonus[1]->text());
    84. saveStat[2] = new QLabel(statBonus[4]->text());
    85. for (size_t i=0; i<3; i++) saveLayout->addWidget(saveStat[i],i+1,3); ///< grab the modifier from the relevant stat, seed to column 4
    86.  
    87. QLabel *saveMisc[3];
    88. for (size_t i=0; i<3; i++) {
    89. saveMisc[i] = new QLabel("0");
    90. saveLayout->addWidget(saveMisc[i],i+1,4); ///< certain classes and races may provide other bonuses to saving throws, seed to column 5
    91. }
    92.  
    93. QLabel *saveTotal[3];
    94. for (size_t i=0; i<3; i++) {
    95. saveTotal[i] = new QLabel("");
    96. int tot = (saveBase[i]->text().toInt()+saveStat[i]->text().toInt()+saveMisc[i]->text().toInt());
    97. QString finalTot;
    98. if (tot >=0) finalTot+="+";
    99. finalTot+=QString::number(tot);
    100. (saveTotal[i]->text())+=QString::number(tot);
    101. saveTotal[i]->setText(finalTot);
    102. saveLayout->addWidget(saveTotal[i],i+1,1); ///< add total bonuses and penalties to saving throws and seed to 2nd column
    103. }
    104.  
    105. saveLayout->setAlignment(Qt::AlignLeft);
    106.  
    107. statsAndSaves->addLayout(statLayout);
    108. statsAndSaves->addWidget(separator5);
    109. statsAndSaves->addLayout(saveLayout);
    110.  
    111. statsAndSavesWidg->setLayout(statsAndSaves);
    112.  
    113. charBones->addWidget(statsAndSavesWidg);
    114.  
    115. QFrame *separator6 = new QFrame;
    116. separator6->setFrameShape(QFrame::VLine);
    117. separator6->setFrameShadow(QFrame::Sunken);
    118. charBones->addWidget(separator6);
    119.  
    120. /////the rest /////
    121.  
    122. QTextEdit *placeholderB = new QTextEdit;
    123. placeholderB->setText("This will hold the rest of the information about the character. This will include Armor Class (AC) (including touch- and flatfooted-AC), initiative bonus, base attack bonus, melee and ranged attack bonus, combat maneuver bonus and defense, hit points, class abilities, number and types of feats, land speed, and vision. Maybe more if I have the time.");
    124. charBones->addWidget(placeholderB);
    125.  
    126. charSheet->setLayout(charBones);
    127.  
    128.  
    129.  
    130. return a.exec();
    131.  
    132.  
    133. }
    To copy to clipboard, switch view to plain text mode 


    Added after 5 minutes:


    Sorry I had to break up main.cpp, but it was too many characters for one post.
    Last edited by recaples; 19th November 2015 at 23:03.

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Undefined reference to '(class name)::connectSignSlot() in moc_(class name).o

    Your linker is telling you that there is no code implementing connectSignSlot(). You only have a declaration that conectSignSlot() exists (line 25 listing 2), but no actual code defining what it does.

Similar Threads

  1. CMake :Undefined reference for a QObject class
    By Zander87 in forum General Programming
    Replies: 2
    Last Post: 8th November 2012, 14:35
  2. undefined reference to vtable in class
    By JeanC in forum Qt Programming
    Replies: 7
    Last Post: 26th February 2011, 10:23
  3. Replies: 1
    Last Post: 5th February 2011, 03:04
  4. Replies: 3
    Last Post: 27th December 2008, 19:34
  5. Reference to a class
    By Gayathri in forum Qt Programming
    Replies: 3
    Last Post: 18th December 2006, 14:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.