PDA

View Full Version : Making an application in C++ for Linux.



solarwind
December 21st, 2007, 01:27 AM
I'm just making a C++ application in Linux as a hobby and would like to license it under the GNU GPL.

It will have a GUI and I am considering using either GTK or QT. I am both a Gnome and KDE fan, I love both of them a lot! Right now, my problem is that I can't decide which gui toolkit to use.

I know GTK is an awesome toolkit and is licensed under the GNU LGPL. However I have a few questions.

1) Which would you prefer using, GTK or QT and why?
2) What's the whole deal with QT and their commercial software stuff that we have to "buy" (yuck!)?
3) Which is "faster"? (Generally.)

I am looking forward to your responses!

Hugolp
December 21st, 2007, 01:33 AM
I have use GTK with C, and it works great.

About the licence GTK is LGPL wich means you can license the resulting program as you wish. You just have to show the code if you modify any part of the library (and only the part of the library you modified, not the whole program). Qt have double license. They are GPL and commercial. That means that if you use Qt and release the program under GPL theres no problem. But if you want to close the code, you need to buy the license from Trolltech.

Hugo

solarwind
December 21st, 2007, 01:38 AM
I have use GTK with C, and it works great.

About the licence GTK is LGPL wich means you can license the resulting program as you wish. You just have to show the code if you modify any part of the library (and only the part of the library you modified, not the whole program). Qt have double license. They are GPL and commercial. That means that if you use Qt and release the program under GPL theres no problem. But if you want to close the code, you need to buy the license from Trolltech.

Hugo

Ahh thanks a lot bro!

One thing though, I love the QT designer and layout system of QT, it's so simple and easy. I have no idea whatsoever how GTK or GLADE works. But I love how GTK is themeable and looks so nice. Is there a similar layout manager for GTK (like QT)?

sharperguy
December 21st, 2007, 01:44 AM
If you want to do GTK and c++ you can use gtkmm which gives you GTK in a c++ wrapper.

GTK's layout works differently to QT's because its works hierarchically (can't believe I spelt that right first time :D). You have container widgets, and nomal widgets.

The main window is a container which hold only one widget, so you'll probably want to be a vbox, hbox or a table in it to let you put in more widgets.

The way it works makes it very easy for the widgets to automatically scale themselves and be in the correct positions when the window is resized.

edit: By the way there's nothing wrong with paying for software as long as it respects your freedoms (I don't know if this stuff does though - anyone else know?)

solarwind
December 21st, 2007, 01:46 AM
If you want to do GTK and c++ you can use gtkmm which gives you GTK in a c++ wrapper.

GTK's layout works differently to QT's because its works hierarchically (can't believe I spelt that right first time :D). You have container widgets, and nomal widgets.

The main window is a container which hold only one widget, so you'll probably want to be a vbox, hbox or a table in it to let you put in more widgets.

The way it works makes it very easy for the widgets to automatically scale themselves and be in the correct positions when the window is resized.

Ok, that's awesome, looks like I'll go with GTK on this one. But I heard the whole glade file system is slow. How do I make it so I don't have to rely on any external xml files for widget data? For example, like everything should be compiled like QT.

slavik
December 21st, 2007, 02:31 AM
separate the gui and the core of the program and then you can have 2 front ends. :)

solarwind
December 21st, 2007, 02:37 AM
separate the gui and the core of the program and then you can have 2 front ends. :)

Thanks for the suggestion, I'll do that. Also, I created a "GTK" c++ application in kdevelop and it gives me several files, one c++ source file which it tells me not to edit but contains vital gtk information. It says it has been created by GLADE but I need to edit it. How do I go about doing this?

Here is the source file:


// DO NOT EDIT THIS FILE ! It was created using glade--
// for gtk 2.8.3 and gtkmm 2.8.0
//
// Please modify the corresponding derived classes in ./src/main_window.cc


#if defined __GNUC__ && __GNUC__ < 3
#error This program will crash if compiled with g++ 2.x
// see the dynamic_cast bug in the gtkmm FAQ
#endif //
#include "config.h"
#include <gtkmmconfig.h>
#if GTKMM_MAJOR_VERSION==2 && GTKMM_MINOR_VERSION>2
#include <sigc++/compatibility.h>
#define GMM_GTKMM_22_24(a,b) b
#else //gtkmm 2.2
#define GMM_GTKMM_22_24(a,b) a
#endif //
#include "main_window_glade.hh"
#include <gdk/gdkkeysyms.h>
#include <gtkmm/accelgroup.h>

main_window_glade::main_window_glade(
) : Gtk::Window(Gtk::WINDOW_TOPLEVEL)
{ main_window = this;
gmm_data = new GlademmData(get_accel_group());
main_window->set_title("gtkprototype Project");
main_window->set_modal(false);
main_window->property_window_position().set_value(Gtk::WIN_POS_ CENTER);
main_window->set_resizable(true);
main_window->property_destroy_with_parent().set_value(false);
main_window->show();
main_window->signal_delete_event().connect(SigC::slot(*this, &main_window_glade::quit), false);
}

main_window_glade::~main_window_glade()
{ delete gmm_data;
}