//honeypot demagogic

 Forum DhammaCitta. Forum Diskusi Buddhis Indonesia

Author Topic: Ask about Qt  (Read 4929 times)

0 Members and 1 Guest are viewing this topic.

Offline tesla

  • KalyanaMitta
  • *****
  • Posts: 6.427
  • Reputasi: 125
  • Gender: Male
  • bukan di surga atau neraka, hanya di sini
Ask about Qt
« on: 13 December 2010, 05:51:00 PM »
kalau dari Qt Creator mau coba buat 1 file executable bagaimana? (bukan project, tp hanya 1 file .cpp)
Lepaskan keserakahan akan kesenangan. Lihatlah bahwa melepaskan dunia adalah kedamaian. Tidak ada sesuatu pun yang perlu kau raup, dan tidak ada satu pun yang perlu kau dorong pergi. ~ Buddha ~

Offline Forte

  • Sebelumnya FoxRockman
  • KalyanaMitta
  • *****
  • Posts: 16.588
  • Reputasi: 458
  • Gender: Male
Re: Ask about Qt
« Reply #1 on: 13 December 2010, 08:04:43 PM »
belum pernah coba.. tetapi setahu gw, qt membutuhkan setidaknya 1 file pro dan 1 file cpp..
file pro itu berguna untuk menyimpan configurasi seperti apakah dijalankan dalam bentuk console / pake gui

misal kandungan yang ada di file .pro :
Code: [Select]
QT       += gui

TARGET = Apps
CONFIG   += app_bundle

TEMPLATE = app


SOURCES += main.cpp \
    apps.cpp

HEADERS += \
    apps.h


Everything can be taken from a man but one thing: the last of the human freedom—-to choose one’s attitude in any given set of circumstances, to choose one’s own way. - Viktor Frankl

Offline Forte

  • Sebelumnya FoxRockman
  • KalyanaMitta
  • *****
  • Posts: 16.588
  • Reputasi: 458
  • Gender: Male
Re: Ask about Qt
« Reply #2 on: 13 December 2010, 08:08:06 PM »
contoh file .cpp nya

Code: [Select]
#include <QtGui/QApplication>
#include <QMainWindow>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QMainWindow *w = new QMainWindow();
    w->setWindowTitle("Hello World");
    w->show();

    return a.exec();
}

hasilnya nanti akan muncul kotak mainwindow dengan titlebar "Hello World"
Everything can be taken from a man but one thing: the last of the human freedom—-to choose one’s attitude in any given set of circumstances, to choose one’s own way. - Viktor Frankl

Offline Forte

  • Sebelumnya FoxRockman
  • KalyanaMitta
  • *****
  • Posts: 16.588
  • Reputasi: 458
  • Gender: Male
Re: Ask about Qt
« Reply #3 on: 13 December 2010, 10:02:45 PM »
Buat bahan belajar.. iseng2.. copas code paritta..

Code: (paritta.pro) [Select]
#-------------------------------------------------
#
# Project created by QtCreator 2010-12-08T20:23:02
#
#-------------------------------------------------

QT       += gui

TARGET = Paritta
CONFIG   += app_bundle

TEMPLATE = app


SOURCES += main.cpp \
    paritta.cpp

HEADERS += \
    paritta.h

Code: (paritta.h) [Select]
#ifndef PARITTA_H
#define PARITTA_H

#include <QMainWindow>

class QLabel;
class QMenuBar;
class QMenu;
class QAction;
class QListWidget;
class QTextEdit;
class QDockWidget;
class QDir;
class QString;

class MainWindow : public QMainWindow
{
    Q_OBJECT;

public :
        MainWindow();

private slots :
        void AboutClicked();
        void SelectFile();
        void RefreshList();

private :
        QListWidget *listwidget;
        QLabel *label;
        QMenuBar *menubar;
        QMenu *mfile;
        QMenu *mview;
        QAction *actabout;
        QAction *actrefresh;
        QAction *actquit;
        QTextEdit *textedit;
        QDockWidget *dockwidget;
        QDir *dir;
        QString curpath;
        QString curOS;
};



#endif // PARITTA_H
« Last Edit: 13 December 2010, 10:10:53 PM by Forte »
Everything can be taken from a man but one thing: the last of the human freedom—-to choose one’s attitude in any given set of circumstances, to choose one’s own way. - Viktor Frankl

Offline Forte

  • Sebelumnya FoxRockman
  • KalyanaMitta
  • *****
  • Posts: 16.588
  • Reputasi: 458
  • Gender: Male
Re: Ask about Qt
« Reply #4 on: 13 December 2010, 10:04:23 PM »
Code: (paritta.cpp) [Select]
#include <QtGui>
#include <QFile>
#include <QMessageBox>
#include "paritta.h"

MainWindow::MainWindow()
{
// Set Title
    this->setWindowTitle(tr("Paritta ver. 1.0"));

// Set Menu
    menubar = new QMenuBar();
    mfile = menubar->addMenu("&File");
    mview = menubar->addMenu("&View");
    actrefresh = mfile->addAction("&Refresh");
    actquit = mfile->addAction("&Quit");
    actabout = menubar->addAction("&About");

// Set ListWidget
    // Prepare listwidget
    dockwidget = new QDockWidget("List");
    curpath= QString(QDir::currentPath());
    dir = new QDir(curpath,"*.txt");
    dockwidget->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
    listwidget = new QListWidget();
    listwidget->addItems(QStringList(dir->entryList()));
    dockwidget->setWidget(listwidget);
    mview->addAction(dockwidget->toggleViewAction());

// Set TextEdit
textedit = new QTextEdit();
textedit->setReadOnly(true);

// Connect

connect(actquit,SIGNAL(triggered()),this,SLOT(close()));
connect(actabout,SIGNAL(triggered()),this,SLOT(AboutClicked()));
connect(listwidget,SIGNAL(itemSelectionChanged()),this,SLOT(SelectFile()));
connect(actrefresh,SIGNAL(triggered()),this,SLOT(RefreshList()));

//Set dock,central widget,etc
this->setMenuBar(menubar);
this->setCentralWidget(textedit);
this->addDockWidget(Qt::LeftDockWidgetArea,dockwidget);
this->showMaximized();
};

void MainWindow::AboutClicked()
{
    QMessageBox::about(this, tr("About Application"),
             tr("Application    : Paritta ver. 1.0    \n\n"
                "Programmer  : Forte "));
};

void MainWindow::RefreshList()
{
listwidget->clear();
dir->refresh();
listwidget->addItems(QStringList(dir->entryList()));
}

void MainWindow::SelectFile()
{
    if (!curpath.endsWith("/") ) {curpath.append("/");};

    QFile rtffile(curpath+listwidget->currentItem()->text());
    if (!rtffile.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        return;
    }
textedit->setText(rtffile.readAll());
}

Code: (main.cpp) [Select]
#include <QApplication>
#include "paritta.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow *w = new MainWindow();
    w->show();

    return a.exec();
}

semuanya dibuat pake handcoded.. jadi gak ada *.ui nya :P

hasilnya seperti di atas..
Everything can be taken from a man but one thing: the last of the human freedom—-to choose one’s attitude in any given set of circumstances, to choose one’s own way. - Viktor Frankl

Offline Sunkmanitu Tanka Ob'waci

  • Sebelumnya: Karuna, Wolverine, gachapin
  • KalyanaMitta
  • *****
  • Posts: 5.807
  • Reputasi: 239
  • Gender: Male
  • 会いたい。
Re: Ask about Qt
« Reply #5 on: 14 December 2010, 07:38:02 AM »
kalo mau compile 1 file, tinggal pake compiler dong.

misalnya compilernya g++

Code: [Select]
g++ main.cpp -o output_executable
HANYA MENERIMA UCAPAN TERIMA KASIH DALAM BENTUK GRP
Fake friends are like shadows never around on your darkest days

Offline Forte

  • Sebelumnya FoxRockman
  • KalyanaMitta
  • *****
  • Posts: 16.588
  • Reputasi: 458
  • Gender: Male
Re: Ask about Qt
« Reply #6 on: 14 December 2010, 07:54:45 AM »
berarti bukan pake qmake nya qt ? pake make aja kan ?
Everything can be taken from a man but one thing: the last of the human freedom—-to choose one’s attitude in any given set of circumstances, to choose one’s own way. - Viktor Frankl

Offline Indra

  • Global Moderator
  • KalyanaMitta
  • *****
  • Posts: 14.563
  • Reputasi: 451
  • Gender: Male
Re: Ask about Qt
« Reply #7 on: 14 December 2010, 08:11:37 AM »
tanya: kenapa memilih Qt? alasan dan pertimbangannya?

Offline Forte

  • Sebelumnya FoxRockman
  • KalyanaMitta
  • *****
  • Posts: 16.588
  • Reputasi: 458
  • Gender: Male
Re: Ask about Qt
« Reply #8 on: 14 December 2010, 08:34:22 AM »
tanya: kenapa memilih Qt? alasan dan pertimbangannya?
- cross platform (unix, windows, mac os)
- bisa belajar C++  :P
- applicable to mobile phone u/ symbian
- lebih cepat dibanding java
- kiblatnya emang lebih ke desktop seh.. :P
- diracuni karuna :))
- terus meracuni tesla :))
« Last Edit: 14 December 2010, 08:38:28 AM by Forte »
Everything can be taken from a man but one thing: the last of the human freedom—-to choose one’s attitude in any given set of circumstances, to choose one’s own way. - Viktor Frankl

Offline Indra

  • Global Moderator
  • KalyanaMitta
  • *****
  • Posts: 14.563
  • Reputasi: 451
  • Gender: Male
Re: Ask about Qt
« Reply #9 on: 14 December 2010, 08:40:11 AM »
- cross platform (unix, windows, mac os)
- bisa belajar C++  :P
- applicable to mobile phone u/ symbian
- lebih cepat dibanding java
- kiblatnya emang lebih ke desktop seh.. :P
- diracuni karuna :))
- terus meracuni tesla :))


kalau dibandingkan dengan lazarus?

Offline Sumedho

  • Kebetulan
  • Administrator
  • KalyanaMitta
  • *****
  • Posts: 12.404
  • Reputasi: 423
  • Gender: Male
  • not self
Re: Ask about Qt
« Reply #10 on: 14 December 2010, 08:47:47 AM »
mending xcode >:D
There is no place like 127.0.0.1

Offline Indra

  • Global Moderator
  • KalyanaMitta
  • *****
  • Posts: 14.563
  • Reputasi: 451
  • Gender: Male
Re: Ask about Qt
« Reply #11 on: 14 December 2010, 08:53:47 AM »

Offline Forte

  • Sebelumnya FoxRockman
  • KalyanaMitta
  • *****
  • Posts: 16.588
  • Reputasi: 458
  • Gender: Male
Re: Ask about Qt
« Reply #12 on: 14 December 2010, 09:01:04 AM »
mending xcode >:D
xcode itu apa ?

kalau dibandingkan dengan lazarus?

lazarus free pascal ya.. mungkin tesla bisa kasih input.. soalnya makanannya dia tuh.. :P
Everything can be taken from a man but one thing: the last of the human freedom—-to choose one’s attitude in any given set of circumstances, to choose one’s own way. - Viktor Frankl

Offline Indra

  • Global Moderator
  • KalyanaMitta
  • *****
  • Posts: 14.563
  • Reputasi: 451
  • Gender: Male
Re: Ask about Qt
« Reply #13 on: 14 December 2010, 09:08:05 AM »
xcode itu apa ?

lazarus free pascal ya.. mungkin tesla bisa kasih input.. soalnya makanannya dia tuh.. :P


xcode adalah development tools di OS X, exclusive di Mac, adakah equivalent compilernya untuk windows?

 [at] Tesla yg sudah memakai keduanya, mohon sharing pengalamannya
« Last Edit: 14 December 2010, 09:12:55 AM by Indra »

Offline Sumedho

  • Kebetulan
  • Administrator
  • KalyanaMitta
  • *****
  • Posts: 12.404
  • Reputasi: 423
  • Gender: Male
  • not self
Re: Ask about Qt
« Reply #14 on: 14 December 2010, 09:09:05 AM »
Xcode is a suite of tools for developing software on Mac OS X, developed by Apple. Xcode 3.2, the latest major version, is bundled with Mac OS X v10.6, but is not installed by default. Instead it must be installed from the Mac OS X DVD, or downloaded for free from the Apple website. The version that is currently available is 3.2.5 that comes with iOS SDK 4.2.
There is no place like 127.0.0.1

 

anything