Find the full script and wiki entry here:

Trying to integrate qmake into Visual Studio or Xcode can be a real pain in the ass. Instead, it’s really not that hard to write a python script to update your moc, ui, and rcc files, since all qmake does is generate makefiles that do a simple date check for each file. Hack and destroy the following code to your liking, and add it as a build step in your favorite IDE:

(Ah yes, and this code tends to run faster than make will!)

This is the basics behind the algorithm, which also runs for UIC and MOC files.

for hpath in HEADERS:
hpath = os.path.join(OUSIA, hpath)
fname = os.path.basename(hpath)
cpath = os.path.join(MOC_PATH, 'moc_' + fname.rstrip('h') + 'cpp')

if not os.path.isfile(hpath):
print 'Skipping non-existing file: ', hpath

dirty = False
if not os.path.isfile(cpath):
dirty = True

if dirty is False and os.path.getmtime(hpath) > os.path.getmtime(cpath):
dirty = True

if dirty:
headerfile = open(hpath, 'r')
while True:
headerline = headerfile.readline()
if headerline == '':
elif 'Q_OBJECT' in headerline:
cmd = MOC_COMMAND + ' ' + hpath + " -o " + cpath
updates += 1