The more I discover Qt's features, the more I feel bad for other libraries' developers.
+1
Oh, god. Qt all the way! (we all knew I'd say this. ;p)
Aside from the language implications of choosing Java, did you hear that there won't be any Swing updates for Java 7? That leaves you with a built-in UI framework from the late 90's which just isn't on top of the times anymore. (
http://www.infoq.com/news/2009/09/java7_m5)
And going back to your original post, you made this argument in favor of Java:
Java is also higher-level, and while I enjoy making my games with C++, I don't know if I have the patience to work with an application at that low of a level
The thing that you need to understand about Qt is that is IS a higher level "addon" to C++ in addition to a powerful GUI library. Qt introduces a framework class library, a form of auto garbage collection, easy work-arounds for RTTI as well as RTTI support, and a powerful notification system similar to delegates that prevent you from having to pass around pointers and references all the time. Oh, and there is "for each" loops. Trendy, eh? ;p
If your worry in using qt is "patience" then you will be pleasantly surprised!
Here is a quick article addressing the one true downside I have found to using Qt, and that relates to templates (not a good first read!):
http://qt-project.org/doc/qt-4.8/templates.html
The article ends by saying this, which is spot on.
C++ with the moc essentially gives us the flexibility of Objective-C or of a Java Runtime Environment, while maintaining C++'s unique performance and scalability advantages. It is what makes Qt the flexible and comfortable tool we have today.
It sounds like maybe you are a bit under informed about what Qt is, so I'll elaborate some. =)
The magic behind Qt all happens because of an extra step they have added to the compilation process, called the "moc." What this does is parse your code and enact lexical replacement in all classes that have the macro, Q_OBJECT. The primary reason for this extra step is to birth a powerful notification system, called "Signals and slots." I'll get to elaborating on this in a sec.
The second part of the puzzle is their framework class library. Similar to Java and C#, everything inherits from QObject. Together, this class library and extra compilation step add the following features to C++:
Code: Select all
@ a very powerful mechanism for seamless object communication called signals and slots
@ queryable and designable object properties
@ powerful events and event filters
@ contextual string translation for internationalization
@ sophisticated interval driven timers that make it possible to elegantly integrate many tasks in an event-driven GUI
@ hierarchical and queryable object trees that organize object ownership in a natural way
@ guarded pointers (QPointer) that are automatically set to 0 when the referenced object is destroyed, unlike normal C++ pointers which become dangling pointers when their objects are destroyed
@ a dynamic cast that works across library boundaries.
Oh goddammit, it's really not worth me explainig because Qt's docs will do it better. :P Before you decide against Qt, just make sure you have read the following about it:
http://qt-project.org/doc/qt-4.8/object.html
http://qt-project.org/doc/qt-4.8/signal ... -and-slots
http://qt-project.org/doc/qt-4.8/qvariant.html
http://qt-project.org/doc/qt-4.8/proper ... rty-system
http://qt-project.org/wiki/How-to-use-signals-and-slots
And, just for the hell of it, here's what code usually looks like in Qt:
Code: Select all
QPushButton *button = new QPushButton;
QObject *object = button;
button->setDown(true);
object->setProperty("down", true);
Notice we don't delete either object--them being QObject derivatives make the calling widget the parent, and will automatically delete their children on destruction. Also, notice how we just pulled a dynamic "property" out of our asshole called "down" and assigned a value to it. Isn't that awesome? ;p
And now, to answer this question:
Does qt essentially have a "markup" for the interface, which is separate from the C++ logic?
Absolutely!...If you want it to.
The .ui files created by Qt's Designer application can be loaded at runtime for a dynamic UI. Here is information on the .ui file that is exported from Qt Designer, which is the UI tool:
http://qt-project.org/doc/qt-4.8/design ... -file.html
(it's basically an XML export).
OR, you can use a more powerful markup language, QML, that has built in JavaScript support:
http://doc.qt.nokia.com/4.7-snapshot/qd ... ction.html
Or you can just use C++ logic, which Falco prefers, since Qt's layout system is so freakin awesome! (
http://qt-project.org/doc/qt-4.8/layout ... youts.html ) . I _seriously_ suggest you check out this basiclayouts article to get a feel for what to expect from Qt before making your decision.
Not only this, but Qt's docs and Qt's IDE are SOOOOOOOOOOOOOO fucking good. Like, seriously. You'll have a hard time using anything else afterwards.
Here's where you'd "Get started" if you choose Qt:
http://qt-project.org/doc/qt-4.8/gettingstartedqt.html
And, here is a full Qt application, just for demonstrative purposes:
Code: Select all
1 #include <QtGui>
2
3 int main(int argv, char **args)
4 {
5 QApplication app(argv, args);
6
7 QTextEdit *textEdit = new QTextEdit;
8 QPushButton *quitButton = new QPushButton("&Quit");
9
10 QObject::connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
11
12 QVBoxLayout *layout = new QVBoxLayout;
13 layout->addWidget(textEdit);
14 layout->addWidget(quitButton);
15
16 QWidget window;
17 window.setLayout(layout);
18
19 window.show();
20
21 return app.exec();
22 }
With the X11 output being:
Would somebody be so kind as to grace me with the java equivalent code? =D
So if I haven't sold you yet...Tell me why not and I'm betting I can remedy it. =) Also, Qt's IRC channel is always flooding with guys who helped make Ubuntu's frontend and are always willing to help.