头文件含有Q_OBJECT macro的编译

Signals and slots is quite easy, check one of the examples and you'll immedeately get away with it.
If you don't have the QMsnet plugin it's a bit of a pain to setup the moc step though, you have to manually add something like this in the .vcproj file (or write a macro that adds a custom build step), for every header that contains a Q_OBJECT macro:

Source code

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

<File RelativePath=".\app\mainapp.h">

	<FileConfiguration

		Name="Debug|Win32"

	>

	<Tool

		Name="VCCustomBuildTool"

		Description="Moc&apos;ing mainapp.h..."

		CommandLine="$(QTDIR)\bin\moc.exe .\app\mainapp.h -o tmp\moc\moc_mainapp.cpp"

		AdditionalDependencies="$(QTDIR)\bin\moc.exe"

		Outputs="tmp\moc\moc_mainapp.cpp"

	/>

	</FileConfiguration>

	<FileConfiguration

		Name="Release|Win32"

	>

	<Tool

		Name="VCCustomBuildTool"

		Description="Moc&apos;ing mainapp.h..."

		CommandLine="$(QTDIR)\bin\moc.exe .\app\mainapp.h -o tmp\moc\moc_mainapp.cpp"

		AdditionalDependencies="$(QTDIR)\bin\moc.exe"

		Outputs="tmp\moc\moc_mainapp.cpp"

	/>

	</FileConfiguration>

</File>


and also add the tmp\moc\moc_mainapp.cpp to your project

same goes for *.ui files except they need uic.exe instead of moc.exe

你可能感兴趣的:(object)