posted by Thanh Ly on Mon 30th Jun 2003 16:08 UTC

"Qt on the Mac, Page 2"
Play time

I wanted to use Project Builder, obviously because it's a neat tool, but the instructions that came with Qt/Mac were pretty vague about how to actually setup a project in PB. So you guessed it, I ran into problems. It would compile everything fine, but when it came to linking and creating the app bundle, I got an error message from the linker saying "missing symbols" and the symbols in question is "vtable for TestApp." TestApp was my QMainWindow widget, it's also the name of the bundle, and there's a TestApp.o as well, so I'm not sure what went wrong. I'm not qualified enough to go further with this issue, but if anyone else has some insight on this matter, please share it. So how was I going to build Qt apps? I went into the "examples" folder and browsed the sample apps to see how things were done. There was a *.pro file in each sample, and upon further research I found out these *.pro files were input for qmake. I didn't know this previously because I've been using KDevelop, which hides most of the build steps for me so I only focused on writing code.

Now I have to learn the command-line way of building software. So I used the example *.pro files as a template to setup my test project. Here's one piece of advice I'll share that I learned from my own mistake: If you copy the sample *.pro file and just change the header and source files it defines for your build, there's one directive at the bottom that goes like this "REQUIRES = full-config". Leaving it in the *.pro file and passing it to qmake will lead to problems, qmake complains about the "full-config" option saying it's not found or installed. This only happens if your working directory is not within the /usr/local/qt directory. Once I moved my project's folder into the examples directory side by side with the other sample apps, qmake was happy. Upon removing the offending line in my *.pro file, I was able to run qmake happily from my home folder. qmake takes the input *.pro file and generates a Makefile for you. The syntax is very simple, in Terminal change to the directory where you have your source and *.pro file.

qmake -o Makefile YourProFile.pro

Afterwards, execute "make" and it begins building your app. Any time you add more source files to your project you'll need to add them to your *.pro file, run qmake on it to get a fresh new Makefile, then build your app. I do miss the comfort of having a nice IDE to code in, but this method works and gets the job done. If you go into the "bin" directory you'll find QT Assistant, which has all the documentation right there for you, with full documentation on how to use qmake. Download a simple template project I've put together.

What does it look like?

Screenshot1 - in the bin directory where you install the Qt source you'll find "qtconfig" which lets you setup global options that affect Qt apps. Shown here is the option to change the widget theme.
Screenshot2 - Qt apps can be themed and the skin can be changed at runtime on the fly.
Screenshot3 - one of the many examples that comes with the package, this one is a collection of examples. In this shot I show off my iBook's 3D capabilities with glxgears!

Conclusion.

Cocoa is the native way of developing software for OSX. My own experience is that it's very hard to unlearn C/C++ and adapt to the mentality and style of Objective-C. I've read comments from other developers in OSX forums who feel the same way. It's probably best to start Objective-C with little or no prior knowledge of C/C++. Carbon apps are written in a procedural fashion but again, it comes down to how a programmer prefers to code, and this programmer doesn't like procedural code... anymore. I have tried Metrowerks' PowerPlant C++ framework, and I do not like it at all. It's not as clean and elegant as Qt, and there's no OpenGL wrapper last I checked. Qt DOES have an OpenGL widget that wraps 3D graphics functionality. I also want to point out that it's not possible to build the Qt lib or apps that link to Qt using Metrowerks' compiler. You must use gcc! My feelings towards Qt in general are all positive. The dual license structure makes it a great framework for people to learn and gain experience on. It also makes it possible to develop commercial applications when the time comes.

Be warned though, Trolltech's FAQ clearly states that you may not use the Free Edition in development and then turn around and buy a commercial license at a later date and sell your software as a product. The Free Edition uses the GPL license and it is in effect from the time you begin development. Trolltech did Apple a big favor by releasing Qt/Mac. Linux developers who are already familiar with Qt will find a smooth transition into MacOSX development. Qt eliminates my concern about "is it worthwhile to develop for MacOSX?" by making it easier to write software for MacOSX and reuse knowledge and skills in a GUI library I'm already familiar with, plus source compatibility with other platforms that use Qt. Now I'm going to go make my own IDE to make it easier for me to write Qt apps in OSX! Because if I see the word "make" one more time...

Table of contents
  1. "Qt on the Mac, Page 1"
  2. "Qt on the Mac, Page 2"
e p (0)    66 Comment(s)