2011年4月8日 星期五

Hello QT (install QT in linux)

Because my system OS is win xp, so I have to use VM for establish linux enviorment.

1. Install VM station.

Choice "Typical" way and just click "next" until it has done.
Sure, you guy should restart computer after installation compeleted.

















2. Install Ubuntu on Virtual Machine.

You can get lastest version of Ubuntu from official web site. (http://www.ubuntu.com/)
Create a new virtual machine in VM workstation and install from image file.

   

















Then completed the installation by yourself, because nothing special need to metion here.

















3. Make sure you can compile C/C++ file

Write a simple Hello.c file for test the function.
#include<stdio.h>
int main()
{
    printf("Hello Ubuntu!\n");
    return 0;
}


run it...
$ gcc -Wall Hello.c -o testc
$ ./testc
$ Hello Ubuntu!
If you can't done this....type the command in terminial for install gcc.
sudo apt-get install build-essential   (Recommand to do this whatever.)

4. Install QT 4 in Ubuntu

Type command below in terminal for QT 4 installation.
sudo apt-get install libqt4-dev         (necessary)
sudo apt-get install qt4-doc            (necessary)
sudo apt-get install qt4-designer     (necessary)
sudo apt-get install libqt4-dbg         (optional)
sudo apt-get install libqt4-gui          (optional)
sudo apt-get install libqt4-sql          (optional)
sudo apt-get install qt4-dev-tools    (optional)
sudo apt-get install qt4-qtconfig      (optional)








Wait about 20 minutes for download and setup automatically.

5. Write HelloQT.cpp file

#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
   QApplication app(argc, argv);
   QPushButton hello("Hello world!");
   hello.show();
   return app.exec();
}


6. Make and Run

Execute command below in turn for make files.
$ qmake -project
$ qmake
$ make


Then run it !
$ ./HelloQT













Reference
http://wallyjue.blogspot.com/2008/08/ubuntu-qt4.html
http://forum.ubuntu.org.cn/viewtopic.php?f=88&t=190878

沒有留言:

張貼留言