"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
- 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.
- 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.
- 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
- The signal and slot mechanisms need to be q_object.
- After you modify a macro such as Q_object, run Qmake to have the MOC regenerate makefile.
- The build command in the IDE (Qt Creator) refers to the make command and does not contain qmake.
Undefined reference to ' Spreadsheet::staticmetaobject '