Getting Started With Using Qt 4 With QDevelop

Creator:
bfr
Description:
Learn the basics of setting up and using the Qt application framework with QDevelop

About Qt

Qt is a toolkit made by Trolltech that mainly is focused on graphical user interface (GUI) programming. It is not just a GUI toolkit, though, containing classes for network programming, database programming, and primitive graphics.

It is also unique in the way that it kind of adds its own "extensions" to C++, which are then processed by the meta-object compiler. These extensions generally make programming Qt easy and fast. Unfortunately, this also makes Qt not work with a lot of integrated development environments (IDEs). QDevelop, specifically designed to be used with Qt 4, works with Qt well, so that's what we'll be using.

Qt comes in two main editions: a commercial edition, which costs money, which allows it to be used in the development of proprietary, or non-open source and free, software, and an open source edition, which is free, and it is what you use if you are developing open source applications - this is the one we're interested in.

Installing Qt and Qt Basics

You can download Qt for the Windows, Mac, and X11 platforms here. If you're using Linux, or another Unix-based operating system besides Mac OS, then the X11 version is for you. In addition, if you're using Linux, you can probably more easily install Qt through repositories - most likely, the ones enabled by default. The packages you'll need will probably be under the names "qt4" and "qt4-devel," and any dependencies will automatically be handled if you're using a decent operating system (just kidding, Slackware and other "stable" operating system users ;)). You'll probably only need to install qt4-devel, and qt4 will automatically be installed, being a dependency.

If you're using Windows, Qt 4 will probably be installed in C:\Qt\4.*.* (replace each "*" with a version number, for example: C:\Qt\4.2.3). If you're using Linux and have installed Qt from a repository, it will probably be installed in /usr/lib/qt4 or /usr/lib64/qt4. If you're on Mac OS, then...well, I'm not sure...I don't know much about Macs...but whatever the installation directory is, it should probably be intuitive. ;) Anyway, navigate to wherever Qt 4 was installed. In the "bin" folder, you'll notice several programs. The ones that you should probably be most concerned about at this point are "qtdemo," "assistant," "designer," and "qmake." "qtdemo" lets you try some interesting and helpful demonstration programs, and it also comes with links to their source code and documentation. "assistant" is a very useful program, providing extensive information about Qt, and essentially being an easy-to-use right-there-when-you-need-it form of the Qt documentation - I highly recommend checking it out sometime. "designer" is a visual What-You-See-Is-What-You-Get (WYSIWYG) editor for Qt - you may not be using this directly much because QDevelop kind of intergrates with it...you'll see. :) And lastly, there is "qmake." Although you probably won't be using this directly much, I thought you should know a bit about it. It's a tool that generates a Makefile for you based off of information from a Qt project file (which has a file extension of ".pro"), simplifing matters grealtly - especially development across multiple platforms.

About QDevelop

QDevelop is a free cross-platform IDE for Qt programming with C++. It integrates well with the components of Qt and is easy to use. Once you get more advanced at programming in C++ with Qt, you might want to switch to using a plain text editor and a command prompt. This is because QDevelop likes things its way, and if you decide to make a very complicated Qt project file with a bunch of odd dependencies or something like that, QDevelop will likely either mess up you're Qt project file or crash, unfortunately (although it is radidly improving its stability). For now, and quite some time, though, QDevelop should be fine.

Installing QDevelop

Go to http://www.qdevelop.org/ and click on "Download." Downloading the correct version should be easy enough...except for a few exceptions. If you're using Linux, first check if QDevelop is in your repositories, and if it is, you should probably download it from there. If not, download the appropriate package from the QDevelop website, and if there are no packages available for your distribution, then just download the "Linux dynamic version with plugins."

Installation should be easy enough. If you're building from the source, make sure you have the necessary dependencies (such as Qt 4, which you should already have).

Using QDevelop

When you first open QDevelop, you'll be prompted for some the paths to the external tools it uses. "gdb," a debugger, and "ctags," which can further assist you while programming, are both handy, but not necessary. And if you're Qt installation was successful, you should be able to fill in most, if not all, of the other fields (except "make"). If you don't have "make" already I recommend getting it from here.

From there...feel free to experiment. :) A few things to note:

- If you click on a .ui file, or a file that is under the "Dialogs" menu, it will most likely be opened with Qt Designer. If you want to view the actual contents of the file with QDevelop, you can simply open it with File->Open.

- If you need to use any of Qt's non-GUI features, you can enable them through Project->Properties of [project name].pro.

- Most of the time, you'll probably want to create a Qt application that uses a main window and not a dialog. The default option in QDevelop is to create a Qt project with a dialog, though. When creating a new project, in the "New project creation" window, simply select the "Application with Main Window" option.

Where to Go From Here

I recommend reading through the Qt documentation, either online (http://doc.trolltech.com/4.3/ contains documentation for the current stable release of Qt) or through the Qt Assistant. There's a good Qt tutorial included within the documentation here, which I particularly suggest you go to.

Comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <b> <u> <i> <hr> <img src <url=
  • Lines and paragraphs break automatically.

More information about formatting options