As for gtk i can say now that i was wrong((( So there will not be any challange because i just do not know gtk on the good level))) some month ago i was choosing DE for using (gnome xfce or kde) and i also looked for information about development native programs for these DE)) that is why i was a bit interested in gtk and Vala)))
here is equivalent in vala
//gtk1.vala
using Gtk;
int main(string argc[])
{
Gtk.init(ref argc);
var wnd = new Window();
wnd.title = "Gtk1";
wnd.set_default_size(300, 50);
wnd.destroy.connect(Gtk.main_quit);
var btn = new Button.with_label("Click me :))");
btn.clicked.connect(() =>
{
btn.label = "Thank you!";
});
wnd.add(btn);
wnd.show_all();
Gtk.main();
return 0;
}
//gtk1.vala
using Gtk;
int main(string argc[])
{
Gtk.init(ref argc);
var wnd = new Window();
wnd.title = "Gtk1";
wnd.set_default_size(300, 50);
wnd.destroy.connect(Gtk.main_quit);
var btn = new Button.with_label("Click me :))");
btn.clicked.connect(() =>
{
btn.label = "Thank you!";
});
wnd.add(btn);
wnd.show_all();
Gtk.main();
return 0;
}
To copy to clipboard, switch view to plain text mode
but now i am using kde that is why i started with qt))) that is why i am here)))
here is FULL QT CODE for this simple program))
//mybtn.h
#ifndef MYBTN_H
#define MYBTN_H
#include <QtGui>
#include <QString>
{
Q_OBJECT
public:
mybtn();
public slots:
};
#endif
//mybtn.h
#ifndef MYBTN_H
#define MYBTN_H
#include <QtGui>
#include <QString>
class mybtn : public QPushButton
{
Q_OBJECT
public:
mybtn();
mybtn(QString title);
mybtn(QString title, QWidget *wnd);
public slots:
void setTxt(QString txt = "hi!");
};
#endif
To copy to clipboard, switch view to plain text mode
//mybtn.cpp
#include <mybtn.h>
mybtn::mybtn()
{
}
{
setText(title);
}
{
setText(title);
}
{
setText(txt);
}
//mybtn.cpp
#include <mybtn.h>
mybtn::mybtn()
{
}
mybtn::mybtn(QString title)
{
setText(title);
}
mybtn::mybtn(QString title, QWidget *wnd) : QPushButton(title, wnd)
{
setText(title);
}
void mybtn::setTxt(QString txt)
{
setText(txt);
}
To copy to clipboard, switch view to plain text mode
//w3.cpp
#include <mybtn.h>
#include <QApplication>
#include <QObject>
int main(int argc, char **argv)
{
wnd.resize(200, 100);
wnd.setWindowTitle("w3");
wnd.show();
mybtn *btn = new mybtn("Press me))", &wnd);
QObject::connect(btn,
SIGNAL(clicked
()), btn,
SLOT(setTxt
()));
btn->resize(100, 25);
btn->move(50, 35);
btn->show();
return app.exec();
}
//w3.cpp
#include <mybtn.h>
#include <QApplication>
#include <QObject>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QWidget wnd;
wnd.resize(200, 100);
wnd.setWindowTitle("w3");
wnd.show();
mybtn *btn = new mybtn("Press me))", &wnd);
QObject::connect(btn, SIGNAL(clicked()), btn, SLOT(setTxt()));
btn->resize(100, 25);
btn->move(50, 35);
btn->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks