Should i even take the time to learn Qt?

May 2, 2013 at 4:26pm
Okay so I installed Qt and have been working around with it a little, following some dude on youtube :D. But I can't help to notice that when creating the UI's, you have to drag and drop the "Button" to where you want it to be... (Using the Qt Creator) Unlike in GLUT where you accually have to program everything. Is Qt just teaching me how to be lazy? Or should i accually be learning Qt?

Thanks, fetz
May 2, 2013 at 5:14pm
Don't know Creator. Designer is older GUI tool to define UI. Design is stored as xml-format. That can be compiled into code or even parsed runtime. Perhaps lazy, but it decouples looks from functionality. That is nice.

You can still write all the code yourself, if you like.
May 2, 2013 at 5:27pm
You CAN create things dynamically in qt creator I never use the Qt Designer/UI.
try this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//header
#include <QMainWindow>
#include <QWidget>
#include <QGridLayout>
#include <QPushButton>
#include <QLineEdit>
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
   MainWindow();

private:
    QWidget *widget;
    QPushButton *btn;
    QGridLayout *layout;
    QLineEdit *line;
};
//Mainwindow cpp
#include "mainwindow.h"
MainWindow::MainWindow()
{
    widget = new QWidget;
    btn = new QPushButton;
    layout = new QGridLayout;
    line = new QLineEdit;

    btn->setText("Click on me!");
    layout->addWidget(line);
    layout->addWidget(btn);
    widget->setLayout(layout);
    setCentralWidget(widget);
}
//main cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}


Check out this link
http://qt-project.org/doc/qt-4.8/qgridlayout.html
Last edited on May 2, 2013 at 6:24pm
Topic archived. No new replies allowed.