Next:
The Regular Approach
Up:
Mini How-To: Qt on
Previous:
Getting Started
The Brute Force Approach
First create a new NetBeans project with the name "HelloQtOnNetBeans" and then perform the following steps:
- Create a new empty source file in the project by right-clicking on the 'Source Files' directory and selecting 'Empty C++ File'; give it the name 'HelloQtOnNetBeans.cc'. Copy the source from the section 'Listing of HelloQtOnNetBeans.cc' of the Appendix into the file and save it.
- Create a new empty header file in the project by right-clicking on the 'Header Files' directory and selecting 'Empty C++ File'; give it the name 'HelloQtOnNetBeans.h'. Copy the source from the section 'Listing of HelloQtOnNetBeans.h' of the Appendix into the file and save it.
- Create a new empty file in the project by right-clicking on the project name 'HelloQtOnNetBeans' and selecting 'Empty C++ File'; give it the name 'HelloQtOnNetBeans.pro'. Copy the source from the section 'Listing of HelloQtOnNetBeans.pro' of the Appendix into the file and save it.
In the NetBeans project-view the source file will appear in the 'Source Files'-section, the header file in the 'Header File'-section and the Qt-project file in the main project section.
In the project-properties view enter the name of the output-file under the link tab: './hello'.
Finally edit the 'Makefile' that you will find in the NetBeans project-section 'Important Files':
- Remove 'build: .build-pre .build-impl .build-post' and replace it with
build:
qmake -o Makefile-Qt HelloQtOnNetBeans.pro
make -f Makefile-Qt
Don't forget to enter a 'Tab' at the beginning of the qmake- and make-line!
- Remove 'clean: .clean-pre .clean-impl .clean-post' and replace it with
clean:
make clean -f Makefile-Qt
Again: don't forget to enter a 'Tab' at the beginning of the make-line!
The line 'qmake -o ..' will automatically create a 'make'-file named 'Makefile-Qt', which is compatible with the GNU C/C++ build-process in the NetBeans C/C++ pack. The process is based on the Qt-project file (here 'HelloQtOnNetBeans.pro') and on the NetBeans C/C++ project properties, you set before. The other lines define the 'make'- and the 'clean'-commands.
Now you can build the program by right-clicking on the project name 'HelloQtOnNetBeans' and selecting 'Build Project'. You can also clean your project or select 'Clean and Build Project' in order to start with a clean environment. Selecting 'Run Project' will start the program and you will see the following window on your screen:
Figure 1.1:The 'Hello Qt' Example
|
|
Your first Qt GUI-program on NetBeans is successfully lunched!
Next:
The Regular Approach
Up:
Mini How-To: Qt on
Previous:
Getting Started
TSSE, 23 October 2008