LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-15-2022, 05:34 AM   #1
olli72
LQ Newbie
 
Registered: Jun 2020
Posts: 18

Rep: Reputation: Disabled
Qt or Glade


Hello forummembers,

i'm started programming as hobbyist in python with linux. in recent times i used ms-windows and visual-products. now i want to do some projects with a graphical-ui and i'm not really aware what to choose. i'm using plasma but it would be nice to use a graphical designer that is flexible to use the programmed stuff also in gnome. what is the better solution, using Qt or Glade or are there other GUI-frontends and what are the pros and cons ?

i appreciate your help
 
Old 08-15-2022, 06:17 AM   #2
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 983

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
The choice is really between GTK and Qt.

Both toolkits are widely-used, and both offer the ability to build state-of-the-art user interfaces.

I prefer GTK because its native API is C-language. GTK is also a relatively small toolkit. It does only GUIs.

In contrast, Qt's native API is C++, and Qt does a lot more than GUIs. You can view the latter either as helping cross-platform development, or creating a monstrosity.

I find that GTK has a slight edge in the look-and-feel department, but that may be because I have spent more effort on GTK. I note that of the large programs that support both, they are generally built with the GTK backend.

GTK's license (LGPL) allows it to be used in both free and proprietary software. You won't have to pay Red Hat.

Since you are running Plasma, you are already looking at Qt. Using Qt would match the appearance exactly.

In summary, there are no bad choices. It comes down to your preferences.
Ed
 
Old 08-15-2022, 08:43 AM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,200

Rep: Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307
Obviously we can’t decide that for you.

Try out both. On each of your target platforms.

The fancy word for that is “evaluating”.

Last edited by dugan; 08-15-2022 at 09:09 AM.
 
Old 08-15-2022, 12:33 PM   #4
olli72
LQ Newbie
 
Registered: Jun 2020
Posts: 18

Original Poster
Rep: Reputation: Disabled
well my main problem is that i was used with visual-products and i still miss events like "form_resize" and till now i haven't find proper tutorials.
 
Old 08-15-2022, 01:06 PM   #5
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 983

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
The GTK 3 documentation is easier to use than the GTK 4 documentation. See https://developer-old.gnome.org/gtk3

You are looking for the configure event.
Ed
 
Old 08-15-2022, 01:46 PM   #6
olli72
LQ Newbie
 
Registered: Jun 2020
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by EdGr View Post
The GTK 3 documentation is easier to use than the GTK 4 documentation. See https://developer-old.gnome.org/gtk3

You are looking for the configure event.
Ed
please no links that are reported as security-leaks
 
Old 08-16-2022, 08:54 AM   #7
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,103
Blog Entries: 6

Rep: Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822
Qt And Gtk are tool kits. There is gtk2 gtk3 gtk4. Qt5 is in use, things are moving to Qt6.
Glade is a User Interface Builder for GTK+ applications.
Qt has designer.
There is also tkinter, fltk toolkits.

If you are using KDE, then QT. Take a look to see what both look like on your machine. Make yourself a couple little demos. Here are gtk2, gtk3 examples.

bclickgtk2.c
Code:
#include <gtk/gtk.h>

void button_clicked(GtkWidget *widget, gpointer data)
{    
    g_print("clicked gtk2\n");
}

int main(int argc, char *argv[]) 
{
    GtkWidget *window;
    GtkWidget *halign;
    GtkWidget *btn;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "GtkButton");
    gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);
    gtk_container_set_border_width(GTK_CONTAINER(window), 15);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);

    halign = gtk_alignment_new(0, 0, 0, 0);
    btn = gtk_button_new_with_label("Click");
    gtk_widget_set_size_request(btn, 70, 30);

    gtk_container_add(GTK_CONTAINER(halign), btn);
    gtk_container_add(GTK_CONTAINER(window), halign);

    g_signal_connect(G_OBJECT(btn), "clicked", 
        G_CALLBACK(button_clicked), NULL);

    g_signal_connect(G_OBJECT(window), "destroy", 
        G_CALLBACK(gtk_main_quit), NULL);

    gtk_widget_show_all(window);

    gtk_main();

    return 0;
}

//gcc bclickgtk2.c -o bclickgtk2 $(pkg-config --cflags --libs gtk+-2.0)
cornbutgtk3.c
Code:
#include <gtk/gtk.h>

int main(int argc, char *argv[]) 
{
    GtkWidget *window;
    GtkWidget *okBtn;
    GtkWidget *clsBtn;

    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *halign;
    GtkWidget *valign;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_window_set_default_size(GTK_WINDOW(window), 350, 200);
    gtk_window_set_title(GTK_WINDOW(window), "Corner buttons");
    gtk_container_set_border_width(GTK_CONTAINER(window), 10);

    vbox = gtk_vbox_new(FALSE, 5);

    valign = gtk_alignment_new(0, 1, 0, 0);
    gtk_container_add(GTK_CONTAINER(vbox), valign);
    gtk_container_add(GTK_CONTAINER(window), vbox);

    hbox = gtk_hbox_new(TRUE, 3);

    okBtn = gtk_button_new_with_label("OK");
    gtk_widget_set_size_request(okBtn, 70, 30);
    gtk_container_add(GTK_CONTAINER(hbox), okBtn);
    clsBtn = gtk_button_new_with_label("Close");
    gtk_container_add(GTK_CONTAINER(hbox), clsBtn);

    halign = gtk_alignment_new(1, 0, 0, 0);
    gtk_container_add(GTK_CONTAINER(halign), hbox);

    gtk_box_pack_start(GTK_BOX(vbox), halign, FALSE, FALSE, 0);

    g_signal_connect(G_OBJECT(window), "destroy",
        G_CALLBACK(gtk_main_quit), G_OBJECT(window));

    gtk_widget_show_all(window);

    gtk_main();

    return 0;
}

//gcc cornbutgtk3.c -o cornbutgtk3 $(pkg-config --cflags --libs gtk+-3.0)
Here is a Qt5 example.

tabwidget.cpp
Code:
#include <QApplication>
#include <QMainWindow>
#include <QTabWidget>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QMainWindow *window = new QMainWindow();

    window->setWindowTitle(QString::fromUtf8("My Qt App"));
    window->resize(500, 500);

    QWidget *centralWidget = new QWidget(window);
    QTabWidget *tabs = new QTabWidget(centralWidget);

    tabs->setFixedSize(500, 500);
    tabs->addTab(new QWidget(),"TAB 1");
    tabs->addTab(new QWidget(),"TAB 2");

    window->setCentralWidget(centralWidget);
    window->show();

    return app.exec();
}

//qmake, then run the Makefile to build.
I'm not a fan of designers or interface builders.
 
Old 08-16-2022, 01:15 PM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,200

Rep: Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307
Quote:
Originally Posted by olli72 View Post
please no links that are reported as security-leaks
???
 
Old 08-16-2022, 03:31 PM   #9
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,103
Blog Entries: 6

Rep: Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822
Quote:
using Qt or Glade or are there other GUI-frontends and what are the pros and cons ?
I kinda glossed over the "using python" part.

Tkinter/Tcl is ideal for python I think. Python will use gtk and QT, just like c/cpp.
You can import the web browser engines, sqlite, urllib etc.

A tkinter demo from my snippets.
That's python3, (tkinter is part of it), tcl/tk
Code:
#!/usr/bin/python

#tkk.Notebook demo

from tkinter import *
from tkinter import ttk

class RootApp(Tk):
    def __init__(self):
        Tk.__init__(self)
        self._frame = None
        self.title('tkk.Notebook tabs demo')
        self.geometry('640x480')
        self.switch_frame(NoteBook)

    def switch_frame(self, frame_class):
        new_frame = frame_class(self)
        if self._frame is not None:
            self._frame.destroy()
        self._frame = new_frame
        self._frame.pack()

class NoteBook(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.notebook = ttk.Notebook(width=640, height=480)
        style = ttk.Style()
        style.configure('TNotebook.Tab', font=('Monospace', '20'))
        self.tab1 = Tab1(self.notebook)
        self.tab2 = Tab2(self.notebook)
        self.tab3 = Tab3(self.notebook)
        self.tab4 = Tab4(self.notebook)
        self.notebook.add(self.tab1, text="Tab1")
        self.notebook.add(self.tab2, text="Tab2")
        self.notebook.add(self.tab3, text="Tab3")
        self.notebook.add(self.tab4, text="Tab4")
        self.notebook.pack()

    def switch_tab1(self, frame_class):
        new_frame = frame_class(self.notebook)
        self.tab1.destroy()
        self.tab1 = new_frame
        
#Notebook Tab 1
class Tab1(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self._frame = None
        self.switch_frame(Tab1_Frame1)

    def switch_frame(self, frame_class):
        new_frame = frame_class(self)
        if self._frame is not None:
            self._frame.destroy()
        self._frame = new_frame
        self._frame.pack()

#First frame for Tab1
class Tab1_Frame1(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.label = Label(self, text='This is Tab 1, Frame 1')
        self.label.config(font=('Monospace','20'), bg='yellow')
        # button object with command to replace the frame
        self.button = Button(self, text="Click this for Frame 2", 
            command=lambda: master.switch_frame(Tab1_Frame2))
        self.button.config(font=('Monospace','20'))
        self.label.pack()
        self.button.pack()

#Second frame for Tab1
class Tab1_Frame2(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.label = Label(self, text="This is Tab 1, Frame 2")
        self.label.config(font=('Monospace','20'), bg='red', fg='white')
        # and another button to change it back to the previous frame
        self.button = Button(self, text="Back to Frame 1", 
            command=lambda: master.switch_frame(Tab1_Frame1))
        self.button.config(font=('Monospace','20'))
        self.label.pack()
        self.button.pack()

#Notebook Tab 2
class Tab2(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.label = Label(self, text='This is Tab 2, Frame 1')
        self.label.config(font=('Monospace','20'), bg='green', fg='white')
        self.label.pack()

#Notebook Tab 3
class Tab3(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.label = Label(self, text="This is Tab 3, Frame 1")
        self.label.config(font=('Monospace','20'), bg='blue', fg='white')
        self.label.pack()
        
#Notebook Tab 4
class Tab4(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.label = Label(self, text="Are you bored yet?")
        self.label.config(font=('Monospace','20'), bg='black', fg='white')
        self.label.pack()

if __name__ == "__main__":
    Root = RootApp()
    #Root.geometry("640x480")
    #Root.title("Frame test")
    Root.mainloop()
And it's small.
Code:
pacman -Si tcl
...
Download Size   : 2.50 MiB
Installed Size  : 6.76 MiB

pacman -Si tk
...
Download Size   : 1925.25 KiB
Installed Size  : 4900.93 KiB
 
Old 08-16-2022, 07:32 PM   #10
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 983

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
I noticed the following on the Glade website:

Quote:
Glade 3.40.0 released
Wednesday 10 August 2022 by Juan Pablo Ugarte

Glade 3.40.0 is now available for download.

This is the last stable release.

Glade is not being actively developed or maintained anymore. If you are interested in becoming a maintainer please contact us on gitlab.
Glade is very useful. I am wondering if funding may have dried up.
Ed
 
Old 08-17-2022, 02:59 AM   #11
olli72
LQ Newbie
 
Registered: Jun 2020
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by teckk View Post
Qt And Gtk are tool kits. There is gtk2 gtk3 gtk4. Qt5 is in use, things are moving to Qt6.
Glade is a User Interface Builder for GTK+ applications.
Qt has designer.
There is also tkinter, fltk toolkits.

If you are using KDE, then QT. Take a look to see what both look like on your machine. Make yourself a couple little demos. Here are gtk2, gtk3 examples.

bclickgtk2.c
Code:
#include <gtk/gtk.h>

void button_clicked(GtkWidget *widget, gpointer data)
{    
    g_print("clicked gtk2\n");
}

int main(int argc, char *argv[]) 
{
    GtkWidget *window;
    GtkWidget *halign;
    GtkWidget *btn;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "GtkButton");
    gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);
    gtk_container_set_border_width(GTK_CONTAINER(window), 15);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);

    halign = gtk_alignment_new(0, 0, 0, 0);
    btn = gtk_button_new_with_label("Click");
    gtk_widget_set_size_request(btn, 70, 30);

    gtk_container_add(GTK_CONTAINER(halign), btn);
    gtk_container_add(GTK_CONTAINER(window), halign);

    g_signal_connect(G_OBJECT(btn), "clicked", 
        G_CALLBACK(button_clicked), NULL);

    g_signal_connect(G_OBJECT(window), "destroy", 
        G_CALLBACK(gtk_main_quit), NULL);

    gtk_widget_show_all(window);

    gtk_main();

    return 0;
}

//gcc bclickgtk2.c -o bclickgtk2 $(pkg-config --cflags --libs gtk+-2.0)
cornbutgtk3.c
Code:
#include <gtk/gtk.h>

int main(int argc, char *argv[]) 
{
    GtkWidget *window;
    GtkWidget *okBtn;
    GtkWidget *clsBtn;

    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *halign;
    GtkWidget *valign;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_window_set_default_size(GTK_WINDOW(window), 350, 200);
    gtk_window_set_title(GTK_WINDOW(window), "Corner buttons");
    gtk_container_set_border_width(GTK_CONTAINER(window), 10);

    vbox = gtk_vbox_new(FALSE, 5);

    valign = gtk_alignment_new(0, 1, 0, 0);
    gtk_container_add(GTK_CONTAINER(vbox), valign);
    gtk_container_add(GTK_CONTAINER(window), vbox);

    hbox = gtk_hbox_new(TRUE, 3);

    okBtn = gtk_button_new_with_label("OK");
    gtk_widget_set_size_request(okBtn, 70, 30);
    gtk_container_add(GTK_CONTAINER(hbox), okBtn);
    clsBtn = gtk_button_new_with_label("Close");
    gtk_container_add(GTK_CONTAINER(hbox), clsBtn);

    halign = gtk_alignment_new(1, 0, 0, 0);
    gtk_container_add(GTK_CONTAINER(halign), hbox);

    gtk_box_pack_start(GTK_BOX(vbox), halign, FALSE, FALSE, 0);

    g_signal_connect(G_OBJECT(window), "destroy",
        G_CALLBACK(gtk_main_quit), G_OBJECT(window));

    gtk_widget_show_all(window);

    gtk_main();

    return 0;
}

//gcc cornbutgtk3.c -o cornbutgtk3 $(pkg-config --cflags --libs gtk+-3.0)
Here is a Qt5 example.

tabwidget.cpp
Code:
#include <QApplication>
#include <QMainWindow>
#include <QTabWidget>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QMainWindow *window = new QMainWindow();

    window->setWindowTitle(QString::fromUtf8("My Qt App"));
    window->resize(500, 500);

    QWidget *centralWidget = new QWidget(window);
    QTabWidget *tabs = new QTabWidget(centralWidget);

    tabs->setFixedSize(500, 500);
    tabs->addTab(new QWidget(),"TAB 1");
    tabs->addTab(new QWidget(),"TAB 2");

    window->setCentralWidget(centralWidget);
    window->show();

    return app.exec();
}

//qmake, then run the Makefile to build.
I'm not a fan of designers or interface builders.
thank you for your efford, i really appreciate your help and advice and will test it. Thank you buddie
 
Old 08-17-2022, 03:06 AM   #12
olli72
LQ Newbie
 
Registered: Jun 2020
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by EdGr View Post
I noticed the following on the Glade website:



Glade is very useful. I am wondering if funding may have dried up.
Ed
is there any successor for glade ? i did not notice this and thank you for the hint. sad to hear because my focus in the last days was indeed on glade because qt is powerful but i think total overkill for my needs and the handling of qt isn't very easy. my impression is that glade is in fact the better choice for rapid developing.

Last edited by olli72; 08-17-2022 at 03:27 AM.
 
Old 08-17-2022, 10:08 AM   #13
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 983

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
Quote:
Originally Posted by olli72 View Post
is there any successor for glade ? i did not notice this and thank you for the hint. sad to hear because my focus in the last days was indeed on glade because qt is powerful but i think total overkill for my needs and the handling of qt isn't very easy. my impression is that glade is in fact the better choice for rapid developing.
We will see what happens. Glade is small enough that any user can keep it working. It may fall behind GTK 4 on new features, but that won't affect GTK 3 users.
Ed
 
Old 08-17-2022, 10:19 AM   #14
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,103
Blog Entries: 6

Rep: Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822
https://glade.gnome.org/

Source, 3.40.0

Code:
_commit=b3823efd0acea2b0a5629b261cf56b1d3f2664aa

git+https://gitlab.gnome.org/GNOME/glade.git#commit=$_commit
 
Old 08-17-2022, 11:10 AM   #15
olli72
LQ Newbie
 
Registered: Jun 2020
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by EdGr View Post
We will see what happens. Glade is small enough that any user can keep it working. It may fall behind GTK 4 on new features, but that won't affect GTK 3 users.
Ed
that might be but i'm afraid if the future isn't clear to ride a dead-horse even if i could use glade for next time. do you have any alternative ide's beside qt and glade that you would use instead ?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Glade 2.5.0 and Perl-Glade-Two - a little help please Lake-end Programming 1 03-07-2005 04:47 AM
Glade and GtkAda AdaHacker Linux - General 1 10-16-2003 10:56 AM
i can't write C++ code in glade amr_azima Programming 1 03-21-2002 02:43 PM
GUI>>glade i want to install C++ compiler amr_azima Linux - Software 1 03-21-2002 02:42 PM
Glade autogen.sh acid_kewpie Programming 0 12-06-2001 08:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration