• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:


How to connect C++ code with QT3
2 Solutions
hi tariq6000,

i guess you want it for windows, if not please tell us for which os you want that.

you have to link your project with qt-mt230nc.lib and qtmain.lib. both are in the "qt-installation-dir\lib". so go to your project-settings and add this in the linker-input-area:


if you have header, which have to be moc'ed, go to the headers-project-settings and add this:

COMMAND: %qtdir%\bin\moc.exe $(InputDir)$(InputName).h -o $(InputDir)moc_$(InputName).cpp
DESCRIPTION: Moc'ing $(InputName).h ...
OUTPUT: $(InputDir)moc_$(InputName).cpp

for this header now a "moc_headername.cpp" - file is generated, this you have to add to your project.

if you have qt-designer-ui-files, you have to add following lines to its settings:

COMMAND: %qtdir%\bin\uic.exe $(InputPath) -o $(InputDir)$(InputName).h
%qtdir%\bin\uic.exe $(InputPath) -i $(InputName).h -o $(InputDir)$(InputName).cpp
%qtdir%\bin\moc.exe $(InputDir)$(InputName).h -o $(InputDir)moc_$(InputName).cpp
DESCRIPTION: Uic'ing $(InputName).ui ...
OUTPUT: $(InputDir)$(InputName).h;$(InputDir)$(InputName).cpp;$(InputDir)moc_$(InputName).cpp

again here is a "moc_uifilename.cpp" - file generated, which has to be added to your project.

tell us, if you have problems making this setup.

good luck :)
1. A easy way is to copy the example project from
And add and remove files as per your requirement.

2. Make your project file and use qmake to do your job.

3. As said by ikework.

If you are new to Qt then I will suggest you to use the first method.


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now