
Challenge submitted by llemes4011
Challenge
Learn to use one or more of the Qt APIs to create a simple application. (Qt is currently on version 4.6)
- Graphics
- OpenGL
- Scripting
- XML
- Unit Testing
- Networking
- Database
- WebKit
- Multimedia
- And more!
Introduce the language/technology
"Qt is a cross-platform application and UI framework. Using Qt, you can write web-enabled applications once and deploy them across desktop, mobile and embedded operating systems without rewriting the source code." Qt is fairly easy to learn, and easy to maintain. It is a great UI API for C++ and has been ported to many other programming platforms. You can write the code on one OS, compile it, run it, then compile the same code on a different OS without changing anything, and get the same application. Many popular programs use Qt - VLC, GoogleEarth, The KDE Environment, and Skype.
Ideas
- Spreadsheet
- Graphical Tic-Tac-Toe game (or similar game)
- File Browser
- Database reader/editor
- Music player
- With Qts extensive APIs, you can make just about any kind of application that you want!
Resources
Qt Download Page - The Qt Designer download comes with a built-in help utility, that has a complete documentation available offline.
The Qt Examples page has many examples that go more in depth with Qt's functionality. If you haven't used Qt before, take a look at the Qt Tutorials page.
Other Platforms
- Qt Jambi -- A Java binding. -- The examples that come with the Qt Creator for Jambi are outstanding.
- PyQt -- A Python Binding.
- Listing of other bindings -- There are other bindings for other languages though not quite as well established.
How to get Started
Getting started with Qt may seem a bit complicated. One you write your first couple applications, you start to see a pattern. I'm going to describe the process for making a GUI.
Qt uses C++'s main function, unlike the WIN32 API. But, Qt uses a "QApplication" object within the main function to define the application. (The Qt Classes all start with a capital "Q" to designate their relationship with Qt.) Look at this example:
#include <QtGui> // The Library that contains ALL of the classes that are used to make GUIs
int main(int argc, char **argv){
QApplication app(argc, argv); // Pass the QApplication the command line args
/* Graphical "Widgets" go here */
return app.exec();
}
Widgets are the components that make up a GUI. Example: A label is a widget, a text field is a widget, the WINDOW is a widget (get the picture?
#include <QtGui> // The Library that contains ALL of the classes that are used to make GUIs
int main(int argc, char **argv){
QApplication app(argc, argv); // Pass the QApplication the command line args
QMainWindow *window = new QMainWindow(); // Create a QMainWindow
window->show(); // Make the window visible
return app.exec();
}
#include <QtGui> // The Library that contains ALL of the classes that are used to make GUIs
int main(int argc, char **argv){
QApplication app(argc, argv); // Pass the QApplication the command line args
QLabel *hello = new QLabel("Hello World!"); // Create a QLabel with text "Hello World!"
hello->show(); // Make the window visible
return app.exec();
}
You'll notice that the spinbox is in its own window, as is the mainwindow. Okay, that's it for my tutorial, check out the official Qt Tutorials here. They offer a better, less rushed tutorial, that is much more detailed.
DIC Tutorials:
Beginning Qt Programming pt.1 by Amrykid
Beginning Qt Programming pt.2: Platforms by Amrykid

New Topic/Question
Reply



MultiQuote










|