(wL) Forums

Full Version: Learning Qt4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is anyone interested in me doing a serious tutorial on how to create a functional application in Qt4 from the ground up? Vote on the poll, if there's enough interest then I'll document my current project as I work on it. Current project that I'm working on is a fairly simple Omegle (omegle.com) chat client. The tutorial would obviously demonstrate UI development, signals, slots, and networking using Qt, code in c++.


---

Qt4 is a widget based framework from nokia, mostly to do with GUI's but they have other APIs too for networking and stuff like that.

Here's a simple Hello World app:

main.cpp
Code:
#include <QApplication>
#include "include/MainWindow.h"

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    MainWindow mainWin;
    mainWin.show();

    return app.exec();
}
include/MainWindow.h:
Code:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QLabel>


class MainWindow : public QMainWindow
{
    public:
        MainWindow();
    protected:
        void closeEvent(QCloseEvent *event);
    private slots:
    private:
        QLabel *container;
};

#endif // MAINWINDOW_H
src/MainWindow.cpp:
Code:
#include "../include/MainWindow.h"

MainWindow::MainWindow()
{
    container = new QLabel(this);
    container->setText("Hello World!");
    setCentralWidget(container);
}

void MainWindow::closeEvent(QCloseEvent *event)
{

}
I hate "Helloworld"s
MindHACKer Wrote:I hate "Helloworld"s


thanks for that lovely contribution!
Isn't this C language?
my particular example is written in c++.


Qt does have c and c++ libraries though.
I almost started using Qt4 from ruby native c extension yesterday, but didn't feel like installing a sane build enviroment for windows where I was gonna use the code. I ended up just settling on java swing (jruby). I'm writing a little google voice desktop sms client.
Leaky Wrote:
MindHACKer Wrote:I hate "Helloworld"s


thanks for that lovely contribution!

;D
It's just that they all post "Hello Worlds", why not post more advanced samples!
MindHACKer Wrote:
Leaky Wrote:
MindHACKer Wrote:I hate "Helloworld"s


thanks for that lovely contribution!

;D
It's just that they all post "Hello Worlds", why not post more advanced samples!

it's an introduction to UI development with Qt, it doesn't just print hello world, it builds a Qt window