How does Qt only use C++ to make custom GUIs for some many platforms? - user-interface

I don't see how Qt does the low level graphics work, in order to create its own custom GUI look/feel for each platform. Does it utilize each of the platforms APIs or something? I ask because I am really wondering how I could go about creating my own framework in order to make a custom GUI application with a unique graphical look.

"How does QT only use C++ to make custom GUIs for some many platforms?"
"Does it utilize each of the platforms APIs ... ?"
You answered your own question. It makes a common library for developers to write their applications with. The application developers write their application only once, not caring about platform specifics. Then, the library author puts out different versions of the library for each platform, which handles all the specific UI calls. This is called encapsulation:
http://en.wikipedia.org/wiki/Information_hiding#Encapsulation
If you were to write your own such library, you would need to figure out what is common between all of the platforms you target, or figure out what high-level concepts your application would need, and create that abstraction. Then, implement that abstraction for each of the platforms you wanted to support.
Edit:
Also see Juliano's comment. This seems like it might be closer to what you want to do, rather than the question you asked. I'd not re-do the work that Trolltech or the WxWidgets team or the Gtk guys or the Mono people did, if I could possibly avoid it.

The good people at Trolltech (now Nokia) write all the platform specific code for you. Only the interfaces to their library remains the same across platforms. You do have to make sure that you only use their classes and don't make any OS-specific calls.
If you want, you can modify the graphics and the handlers to extend the Qt library and create your own look and feel.

Your Qt application doesn't have to have the plain standard platform graphical look, but there are ways to design unique apps with Qt.
For instance, you can style your application with style sheets: http://doc.qt.io/qt-5/stylesheet.html, or even with a custom QStyle (which is not very easy): http://doc.qt.io/qt-5/qstyle.html
Qt Quick is a new technology we're introducing in the upcoming Qt 4.7 (check out the beta if you're interested). It allows you to easily define custom UI components from simple primitives, with custom animations, state transitions and other effects. See for example http://www.youtube.com/watch?v=8G4U7QWRajg.

Related

Best framework for creating desktop applications with dynamic GUI

Sorry for the unusual question, but I don't know where else to ask this.
Basically I would like to know what a good framework is for creating applications(mostly Windows, but wouldn't hurt if it would be cross platform) that would allow to do fancy GUI animations, transitions and is easily modifiable.
I worked with the swing library for java so far. Its a solid GUI library but its completely static.
Here an examples for showing off what I mean: Atom.io
QT is an excellent choice for app and UI development. The API is C++ (though many other bindings are available) and it has a solid IDE and UI building. It is free to use for non-commercial work. https://www.qt.io/

Doing native GUI with Ruby

I'd like to develop a desktop app with Ruby. However, I'd like to have a native GUI on every platform (as opposed to a cross-platform GUI Toolkit that looks consistently awful across all platforms).
I expect to have to do different GUIs for each platform (as it's not just looks but also behaviors and idioms that are different), but I wonder what my options are? Especially wondering if there is a clean way to separate front and backend and bind the data properly?
Target Platforms are Windows (Vista & 7, XP is a Bonus), Mac OS X (Cocoa) and Linux (GTK? Qt? No idea).
The Ruby language has excellent Qt library bindings and your scripts will be cross-platform.
Two Kinds of Cross-Platform
It turns out there are two kinds of cross-platform UI toolkits.
One kind draws its own controls, and, like you said, looks equally bad on all platforms. Even worse: it looks out-of-place on all except one.
But there is another kind that just provides a harmonized interface to the native widgets. The best of example of this kind of toolkit is SWT1.. It looks, it is, approximately fully native on each platform, yet it has but a single API.
So you shouldn't simply rule-out all cross-platform toolkits, just rule out the ones that fake the native UI.
Develop the Wrapper Interface
There is a second way. If your program's interface with the user can be directed through a relatively narrow interface, you can simply develop to that interface and then implement the bottom part of it for each platform you want to support. Yes, you have to rewrite one module, but all the other modules stay exactly the same and you get native widgets. You also get the smallest possible executable without lots of bloat.
Perhaps most importantly, you don't have a complex and opaque software layer between your code and the native windowing system. You will probably save as much time debugging as you spend writing the extra module for your first port.
1. I know my Java examples won't help you much unless you are using jRuby, but SWT vs Swing is a really pure example of the right-vs-wrong (IMHO) UI toolkit divide.
The WxWidgets interface claims to use the native interface on Windows, OS X, Linux and UNIX through one API.
Coworkers who have used it in the past enjoyed it well enough, but I've not used it myself.

What language can create relatively quick starting cross-platform applications with custom widgets?

I want to create an application that "plays well as a tray icon". That is, it starts up quick and doesn't hog resources. The application will likely need some custom UI widgets as well, and although I mention "tray icon", cross-platform would be ideal as well.
Obviously, I can do this with C++ and some cross-platform UI library (I wouldn't know which one), but I was hoping for a language with garbage collection.
I can do this with Java, but I'm guessing even after compilation, it likely builds a relatively large and slow-starting .exe (maybe the SWT UI library would cut some bloat?). Another way to ask this question, is it possible in Java, and if so what is the best way to make quick/snappy app? I want it pop up similar as popping up Google Desktop search.
Is there something "between Java and C++?"
So,
* Higher-level than C++ (mainly GC)
* Quick starting and resource friendly/snappy (.exe or otherwise)
* Cross-platform desktop UI (even with custom UI widgets)
Try Python it is a high level cross-platform language with GC.
Use Qt and pick an arbitrary supported language
Here is the link to it : Qt - A cross-platform application and UI framework
You can use it freely if you don't develop commercial application.
The reference documentation is very good, and you can find a lot of help all over the net.
It uses a hierarchy of the objects, and if a parent object destroys, it frees up all the children. In a GUI app you don't have to bother with deallocations, if you use the proper syntax. I am developing a 2D presentation application for linux with it, and I am very satisfied with its performance.
Don't forget to use Qt Creator if you decide to use Qt, it simplifies project creation, contains "intellisense", very useful. Without it Qt is a pain..
Supported programming languages: (quoted from qt site)
Programming Language Support
The Qt API is implemented in C++, and
provides additional features for
easier cross-platform development. QML
– introduced with Qt 4.7 – QML is a
JavaScript-based declarative, language
designed to describe the user
interface of a program: both what it
looks like, and how it behaves.
Bindings to Qt exist for several other
languages, including Ada, Pascal,
Perl, PHP, Ruby, Python and Java™.

Differences that matter between GTK+ and QT?

What are the finer differences between QT and GTK+?
Specifically I need to know the finer differences.
Language neutral, Windows/Linux neutral. Just the finer points please...
How native are the widgets / controls to the window manger, from its standpoint? Example: If it were a text control, would it process: a WM_COMMAND or EM_SETSEL message sent to it? If not, how do third-party applications / screen readers interact with the control / widget?
Advanced widgets available in one toolkit and not available in the other? Add-Ons are fine to describe.
What is the quality of theming from a multimedia / special effects standpoint? like powerpoint style special effects such as fade-ins of widgets/docks. What's the ease of coding for these scenarios?
Note: I'm probably biased towards Qt as I never used GTK seriously.
Qt's graphics view and scene system is awesome, GTK only has low level Cairo.
Writing custom widgets seems easier with Qt, probably because of the OO design. I don't know which API has more "advanced" widgets, but the basic ones are probably enough for most applications with a little bit of customization.
If you want a completely custom display for your app with special effects and all, you can easily write one based on graphics view/scene. Qt 4.7 also adds Qt Quick to design fancy interfaces, I didn't have the opportunity to test it yet but it looks pretty cool.
Overall I think both are great frameworks and offer enough for any application, but with Qt you get everything in a nice package, when you have to use 3rd party additions or reinvent the wheel to get the same job done with GTK.
Although you didn't ask this, it's worth pointing out the different philosophies between Qt and Gtk+ (or Gtkmm, the C++ version of Gtk+).
Qt is a full application development toolkit. It includes XML parsers, concurrency framework and so on. Gtkmm is not. From the gtkmm documentation:
gtkmm is a GUI toolkit and nothing
more, and it strives to be the best
C++ GUI toolkit. That mandate does not
cover generic C++ data structures, an
XML parser, or database access.
The probably more fair comparison is between Qt and Gtkmm + a set of GNOME libraries.
For advanced widgets the GNOME libraries are really nice - take libgoffice, for example. But it doesn't have a beginner friendly documentation and you will end up having to ask questions in the mailing lists or the IRC channels. Qt is also very nice and have a much friendly documentation. The quality and availability are equivalent, in my opinion, but Qt usually have more documentation or, at least, is documented in a way more friendly to "outsiders".
Both have high quality presentation and effects. No meaningful difference. I like the Gtk+ appearance more than Qt, but it just a matter of personal taste.
Not a complete answer, but:
I find it really difficult to
customize widgets in Gtk+, e.g. I
want the behavior of widget X, but
need to tweak the look beyond the
usual style settings.
OTOH I don't like Qt's moc, but that's more of a
personal thing.
I'd also strongly
recommend Gtkmm (the C++ wrapper)
over plain Gtk+.
Sorry if this bias to qt and shallow
Qt has many eyecandy effect ( dont know about gtkmm).
Qt has Qtconcurrent, higher level api for multithreading. probably more readable
than Qthread Qmutex blablabla...
Based from your question I think you want to integrate desktop app to www,
so just compare for yourself between qtwebkit , gtkhtml and gtkwebkit which one is likely to fit you better.
I've narrowed it down to XULRunner or GTK+.
Here's why:
I need to quickly become familiar with the internals. QT makes this difficult for me with so much on their ease-of-use solutions.
QT is HUGE! I stopped a custom compile after it had been running for over 4hrs on my 3Ghz P4! to be fair, QT provides many precompiled binaries
Out of the box themes for QT are rather too 'professional' looking. I need something cool, GTK+ has some neat themes which I can modify.
I don't need / want to use the framework for networking, file management, multimedia, webkit, or anything besides a GUI frontend to other apps.
Note that the license in Qt is LGPL which is not good enough for many commercial projects. Same for GTK+, but at least you can pay for legally using Qt in commercial projects.

How to decide GUI Framework for desktop application project

I am working on a new small utility desktop application but I am not really able to choose the GUI framework to use. I have worked on both JAVA,C# and C++, so language is not really a constraint. My criteria are:-
A very well designed architecture, something like QT. It's better if it follows typical C++ design methodologies.
Layout management should be easy, intuitive and not really cumbersome. I hate adjusting pixels on screen.
Its license should be open.
It should look good :)
Mentioned QT seems to comply to all your requirements. QT has "deploy everywhere" attribute, whilst Java needs no deploying at all (it depends on what is use of your utility).
Ad. 2 QT has really convenient GUI designer.
Ad. 3 LGPL. Usually it is enough.
Ad. 4 It is always matter of taste. IMO QT4 looks awesome under linux, but it's windows look'n'feel is correct at best. It's strong point is, that without additional tweaks it almost everywhere looks native.
I've been using Swing, and it works fine. NetBeans (a decent IDE by itself) even supports graphical GUI building.
It's well designed (basically
everything is done with listeners,
functions that are registered for a
certain event). It has bindings, so
you don't have to write code to set
up a value in a text field or read
it out
Layout is not perfect, but
acceptable within NetBeans. It's
WYSIWYG (almost). Look-and-feel can
be changed on the fly.
License is free. Source-code is not
available, I think.
Looks fine on Windows and Linux,
less so on OSX.
You could always try SWT. The advantages of Java with the standard L&F of supported operating systems.
Well designed. Lots of
documentation, and very easy to
develop with. (If you know Swing,
you can pick up SWT in no time.)
I believe layout managers do exist
that support SWT. I'm not positive
about this though, as I typically
don't use layout managers too much.
Uses the Eclipse Public
License. Should meet most of
your requirements.
From Wikipedia on SWT:
SWT is written in Java. To display GUI elements, the SWT implementation accesses the native GUI libraries of the operating system using JNI (Java Native Interface) in a manner that is similar to those programs written using operating system-specific APIs. Programs that call SWT are portable, but the implementation of the toolkit, despite the fact that it is written in Java, is unique for each platform.
Hope that helps you.
I'd suggest wxWidgets if you want to program in C++ or wxPython (the python language binding of wxWidgets if you know or don't mind learning Python.
Architecture is similar to QT I think.
Layout using sizers. Quite easy once you get the hang of it.
Liberal open source license.
Widgets are native on all platforms (Windows, Mac OS X, Linux).

Resources