Undefined reference to ' Spreadsheet::staticmetaobject '

Source: Internet
Author: User

"C + + GUI Qt 4 Programming" learning

First, the problems encountered
    • After studying the 4th chapter, the Spreasheet program has been written as well. Found no effect when searching with Finddialog.
Ii. process of Settlement
    1. Debugging the trace code, after discovering the emit signal function, the slot function is not called, so it should be a signal and slot connection problem.
    2. During the run of the program in debug mode, no such slots and no such signa are indicated in the program output.
      If a class is known to use a signal and a slot, you need to add a Q_object macro to the class definition. After comparing with the code in the book.
      Find out that this macro is really missing.
    3. After adding the Q_object macro, run the build, prompting for an error. In addition to the errors of several signal and slot functions, there are
      "Undefined reference to ' spreadsheet::staticmetaobject '" This error hint. This is supposed to be
      MoC this thing is out of the problem. Search for a bit, there is a similar problem on the StackOverflow. The answer states:
      "Remember to re-run qmake every time you add or remove q_gadget or
      q_object macro to get MOC tool to re-generate code for meta data. "After performing Qmake
      Re-build, problem elimination.
Third, knowledge points
    1. The signal and slot mechanisms need to be q_object.
    2. After you modify a macro such as Q_object, run Qmake to have the MOC regenerate makefile.
    3. The build command in the IDE (Qt Creator) refers to the make command and does not contain qmake.

Undefined reference to ' Spreadsheet::staticmetaobject '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.