• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • 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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

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