create Qt applications on Windows using Microsoft Visual C + + 2008 (Compile, Debug and Run from the IDE) Hello, for those who do not know what Qt is a cross-platform API for creating native applications on Windows, Linux, Mac, Solaris, etc and to carry them without changing a line of code. If you want to see more information about this package visit:
http://www.qtsoftware.com/
I had already written two posts on this blog and how to install Qt on Linux, if you want to give them a look: Replacement of Visual Basic
Install Qt4 The truth is that he had been trying to run this package on Windows but so far had failed, I tried to DevCo + + and Eclipse but nothing, who think that the solution was a product of Microsoft.
Recently Microsoft released the Express versions of Visual Studio 2008
that can be downloaded free. With this product we can compile Qt and also create your own applications. In this post I will explain how.
Obviously the first thing is unloaded and install the Visual C + + 2008 Express Edition, when installed (it weighs about 150 MB) must download the Source Code for Windows Qt4 page
Qt Software. Eye, do not download the version that comes with MinGW but it's just source code. The download weighs 120 MB, is a compressed file.
Download the file and unzip it in C: \\ Qt \\ 4.4.3
[FOLDER NAME should not contain spaces]
(the 4.4.3 was the version I got but it may be that the time you read this is a more recent post.) In that folder is a file called autconf configure.exe this is the builder, run it BUT
to Start -> All Programs -> Microsoft Visual C + + 2008 Express Edition -> Visual Studio Tools -> Command Prompt Visual Studio 2008, this will open a console in the directory of Visual C + + and enables paths to the maker, and the linker. In this console will go to C: \\ Qt \\ 4.4.3 \\ (or the directory where you have unpacked the qt), once there run:
C: \\ Qt \\ 4.4.3 \\> configure-platform win32-msvc2008 This statement sets the code so that it can compile with the compiler of Microsoft Visual Studio 2008, once the process Temin see a message like this: Qt is now configured for building. Just run nmake. To reconfigure, run nmake confclean and configure.
Then just do what we said there, run nmake to start Visual C + + to compile. This process takes a while, as in Linux, the console will be compiled for a time creating the executables of Qt Designer, Qt Assistant, moc, etc and Qt dll, when the process terminates Qt is compiled and installed in equipment ready for use.
Now let's see how to create a software in Qt using Visual C + +, we create the Hello World Tutorial Qt. But first we must do something extra and add the Qt bin folder to the System Path: We click Home
and then right-click My Computer
, there are going to
Properties tab and the Advanced Degree Options
we click on
Environment Variables, dialog box appears with the system variables and variables user in the system variables we variable
Path, select it and we click Edit
. At the end of the text we put a, (semi-colon) and then write the bin path of Qt, which in my case was C: \\ Qt \\ 4.4.3 \\ bin and we click OK
in all dialog boxes .
Now if we create the Hello World.
Open the Visual C + + 2008 and we believe a New Project, which says
Project Type select Visual C + +
-> General
-> Makefile Project
. Select the location and name of the project here will be Hello World. We removed the checkbox
Create directory for solution and we click OK .
Visual Studio opens a configuration wizard Makefile project, we'll ignore it and simply click Finish
. The project will create the folders and files appear usual Visual C + + (creates a lot of garbage).
Let's create the main, then, in the
Solution Explorer , folder
Source Files we right click and there select
Add
->
New Item
and we choose
File C + + (. cpp) , we name
main and click on OK
.
Visual Studio opens the code editor, there are going to write code that is in the Qt Assistant, in the Hello World tutorial is this:
# include \u0026lt;QApplication>
# include \u0026lt;QPushButton>
int main (int argc, char * argv []) { QApplication app (argc, argv);
QPushButton hello ("Hello world!");
hello.show ( )
app.exec return ();}
We Save and you're ready the project, now the bad news, we can not build from the IDE (or at least I do not I have that need to configure it and I have not put in those) so let's compile the console:
again
Open Command Prompt Visual Studio 2008 to compile the Qt open. In the console go to the folder where we saved the Visual C + + and there write these commands:
qmake-project qmake
nmake
This compiles the program and creates the executable in the folder Debug, in my case world.exe Hello. From the same console or from Windows Explorer can run the application to make sure it works.
Well, we have created and executed an application on Windows with Qt. If you run the Hello world run anything. :)
Feel free to leave your comments, questions or concerns.
care is Bye Bye.